Enable Gradle native support programmatically

已回答

I have an ability to add dependency on test framework library programmatically: I need to call JavaProjectModelModificationService.addDependency method with framework library descriptors for it. After that there is the following code in my build.gradle file

dependencies {
implementation 'org.testng:testng:6.9.6'
implementation 'org.junit.jupiter:junit-jupiter:5.8.1'
}

But I would also like to add programmatically the following section to my build.gradle

test {
useJUnit()
useTestNG()
useJUnitPlatform()
}

What is the correct way to do it?

评论操作 固定链接

There is currently no API for modifying existing Gradle build script for this use case. For creating Gradle build script from scratch there's org.jetbrains.plugins.gradle.frameworkSupport.buildscript.GradleBuildScriptBuilder.

0
评论操作 固定链接

Yann Cebron, thanks for your reply. Could you suggest another way to solve a problem with conflicts of added by our plugin tests dependencies in user's project, that has already been created with his own Gradle script?

0
评论操作 固定链接

If you mean checking for existing definition of dependencies, you could use com.intellij.externalSystem.ExternalDependencyModificator

0

请先登录再写评论。