gradle-custom-plugin

Programmatically invoke a gradle task graph in a unit test

泪湿孤枕 提交于 2020-01-01 02:16:28
问题 I am in the process of writing a custom plugin for gradle and as part of the unit testing I would like to invoke my task but in such away as it's prerequisite tasks are executed. The actual plugin is unfortunately an internal project so I can't sure the exact source, but I have prepared a unit test that demonstrates the problem: package toy import org.gradle.api.Project import org.gradle.testfixtures.ProjectBuilder import org.junit.Test class ToyTasksTest { boolean task1Run = false boolean

How to allow user to change the version of the library which is used by a plugin in Gradle?

余生长醉 提交于 2019-12-11 12:57:06
问题 In my plugin I call static bootstrapping method MutationCoverageReport.main(arg) from a library which is a compile dependency of my plugin. I would like to allow a plugin user to change the version of the library which should be used (assuming the selected version has compatible API). I could advice user to exclude a transitive dependency from my plugin and add a dependency to the library in the requested version manually to buildscript.dependencies.classpath in his build.gradle, but this is

How to configure Gradle Java plugin from a custom Gradle plugin

巧了我就是萌 提交于 2019-12-11 07:59:26
问题 I've written a custom Gradle plugin in Kotlin 1.2.50 for use with Gradle 4.8. I've successfully applied the Java plugin from my plugin's apply method: override fun apply(project: Project) { project.pluginManager.apply(JavaPlugin::class.java) // configure Java plugin here } How do I configure the Java plugin? e.g., I want to achieve the equivalent of the following that would normally be in a build.gradle.kts : java { sourceCompatibility = VERSION_1_10 targetCompatibility = VERSION_1_10 } 回答1:

Execute Java class with separate classpath from Gradle plugin

孤人 提交于 2019-12-08 02:41:32
问题 In my plugin I need to execute static bootstrapping method from an external JAR to perform an analysis. Currently I call it directly from code with MutationCoverageReport.main(arg) , but this forces me to create a compile time dependency in my plugin which is hard to modify (choose a different JAR version) when executing the plugin. I would like to call it using reflection and found some examples in Gradle code like WorkerProcessBuilder or JavaExecHandleBuilder . Nevertheless they are in org

Execute Java class with separate classpath from Gradle plugin

雨燕双飞 提交于 2019-12-06 05:23:08
In my plugin I need to execute static bootstrapping method from an external JAR to perform an analysis. Currently I call it directly from code with MutationCoverageReport.main(arg) , but this forces me to create a compile time dependency in my plugin which is hard to modify (choose a different JAR version) when executing the plugin. I would like to call it using reflection and found some examples in Gradle code like WorkerProcessBuilder or JavaExecHandleBuilder . Nevertheless they are in org.gradle.process.internal package and I'm not sure if it is recommended to use it from the external