Gradle Custom Plugin: gradleApi () vs Explicit Dependency

I am developing a custom gradle plugin and the dependencies for my plugin project are as follows:

dependencies { compile gradleApi() compile localGroovy() compile('com.xxx.oozie:oozie-dsl-parser:1.0.127') { exclude module: 'groovy-all' } testCompile('org.spockframework:spock-core:1.0-groovy-2.3') { exclude module: 'groovy-all' } } 

However, in the interest of reproducible builds, I wonder if it localGroovy() sense to use localGroovy() and gradleApi() .

After much searching, although I could replace localGroovy() with a specific version of groovy, I cannot find a definitive answer for what I would replace gradleApi() with.

Do you have any suggestions?

Thanks!

+6
source share
2 answers

I suggest applying java-gradle-plugin . It automatically adds the gradleApi() dependency, and also includes some other template configurations: https://docs.gradle.org/current/userguide/javaGradle_plugin.html#gsc.tab=0

The version of gradleApi() , which is added as a dependency, depends on the version of Gradle that you use to build the project. For example, if your wrapper has Gradle 2.14.1, the Gradle API used will be this version.

You also don't need to worry about localGroovy() , because it is already included in the gradleTestKit() dependency added by the plugin: https://docs.gradle.org/current/userguide/test_kit.html#sub:test-kit-automatic- classpath-injection & gsc.tab = 0

Here is an example:

 apply plugin: 'groovy' apply plugin: 'java-gradle-plugin' dependencies { testCompile('org.spockframework:spock-core:1.0-groovy-2.4') { exclude module: 'groovy-all' } } 
0
source

Looking at https://github.com/gradle/gradle/issues/1835, it seems that there is no explicit dependency that you can use for this purpose.

Although this is not equivalent to gradleApi() , if you are developing for Android, you might be interested in the com.android.tools.build:gradle-api:3.3.2 dependency.

-1
source

All Articles