Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the version numbers of bulit-in gradle plugins?

Tags:

java

gradle

In my gradle build file, I have the following plugin block

plugins {
    `java-library`
    jacoco
    checkstyle
}

None of these specify a version but everything works.

Assume that a project is using gradle 6.0 with the gradle wrapper but the system has gradle 5.0 installed.

Questions:

  • If I run gradle wrapper ./gradlew build the java plugin from gradle 6.0 will be executed. Is this true or false?
  • If I run system gradle gradle build the java plugin from gradle 5.0 will be executed. Is this true or false?
  • Are these plugins bundled into the gradle distribution itself or are they downloaded from the gradle plugin portal on demand?
  • Is the build considered to be non-reproducible (like it is in maven) because the plugin versions were not set?
  • What are the gradle best practices around plugin versions should they be set or left off?
like image 255
ams Avatar asked Oct 15 '22 07:10

ams


1 Answers

Gradle distinguishes between core and community plugins. Core plugins are built into the Gradle distribution and can be referenced by their unqualified short name ("java" vs. "org.gradle.java"). They're not retrieved from the plugin portal. Core plugins must not include a version constraint (Javadoc Reference). Find the list of core plugins here.

Community plugins are hosted and retrieved from the plugin portal. They must be given in the fully qualified plugin ID along with a version.

Find out more about plugins in these guides:

  • Using Gradle Plugins
  • Interface PluginDependenciesSpec

If I run gradle wrapper ./gradlew build the java plugin from gradle 6.0 will be executed. Is this true or false?

True, since the Gradle Wrapper ensures the build is run with the specified Gradle version and core plugins are bundled with the distribution.

If I run system gradle gradle build the java plugin from gradle 5.0 will be executed. Is this true or false?

True.

Are these plugins bundled into the gradle distribution itself or are they downloaded from the gradle plugin portal on demand?

Bundled, as explained earlier.

Is the build considered to be non-reproducible (like it is in maven) because the plugin versions were not set?

The build can be considered reproducible as long as the same Gradle version is used since the core plugins are bundled with the distribution.

What are the gradle best practices around plugin versions should they be set or left off?

As explained earlier, you don't have a choice here. Core plugins must not define a version whereas community plugins must be along a version.

like image 128
thokuest Avatar answered Nov 15 '22 09:11

thokuest