Interface JavaPluginExtension
JavaBasePlugin and would be more appropriately named
 the JvmPluginExtension extension.  It is used to configure many of the project's
 JVM-related settings and behavior.- Since:
- 4.10
- 
Method SummaryModifier and TypeMethodDescriptionvoidconsistentResolution(Action<? super JavaResolutionConsistency> action) Configure the dependency resolution consistency for this Java project.voidIf this method is called, Gradle will not automatically try to fetch dependencies which have a JVM version compatible with the target compatibility of this module.booleanTells if automatic JVM targeting is enabled.Returns a file pointing to the root directory supposed to be used for all docs.Configure the module path handling for tasks that have a 'classpath' as input.Returns the source compatibility used for compiling Java sources.The source sets container.Returns the target compatibility used for compiling Java sources.Returns a file pointing to the root directory to be used for reports.Returns a file pointing to the root directory of the test results.Gets the project wide toolchain requirements that will be used for tasks requiring a tool from the toolchain (e.g.manifest()Creates a new instance of aManifest.Creates and configures a new instance of aManifest.Creates and configures a new instance of aManifest.voidregisterFeature(String name, Action<? super FeatureSpec> configureAction) Registers a feature.voidsetSourceCompatibility(Object value) Sets the source compatibility used for compiling Java sources.voidSets the source compatibility used for compiling Java sources.voidsetTargetCompatibility(Object value) Sets the target compatibility used for compiling Java sources.voidSets the target compatibility used for compiling Java sources.sourceSets(Closure closure) Configures the source sets of this project.toolchain(Action<? super JavaToolchainSpec> action) Configures the project wide toolchain requirements for tasks that require a tool from the toolchain (e.g.voidAdds a taskjavadocJarthat will package the output of thejavadoctask in a JAR with classifierjavadoc.voidAdds a tasksourcesJarthat will package the Java sources of the mainSourceSetin a JAR with classifiersources.
- 
Method Details- 
getSourceCompatibilityJavaVersion getSourceCompatibility()Returns the source compatibility used for compiling Java sources.
- 
setSourceCompatibilitySets the source compatibility used for compiling Java sources.This property cannot be set if a toolchainhas been configured.- Parameters:
- value- The value for the source compatibility
- See Also:
 
- 
getTargetCompatibilityJavaVersion getTargetCompatibility()Returns the target compatibility used for compiling Java sources.
- 
setTargetCompatibilitySets the target compatibility used for compiling Java sources.This property cannot be set if a toolchainhas been configured.- Parameters:
- value- The value for the target compatibility
- See Also:
 
- 
registerFeatureRegisters a feature.The new feature will have a default capability corresponding to the "group", "name" + feature name and version of this project. For example, if the group of the component is "org", that the project name is "lib" the version is "1.0" and the feature name is "myFeature", then a capability named "org:lib-my-feature:1.0" is automatically added. In order to consume this feature in another module add a dependency like the following: dependencies { implementation(project(":lib")) { capabilities { requireCapability("org:lib-my-feature:1.0") } } }TheFeatureSpec.capability(String, String, String)method can be used to refine the capabilities of this feature.- Parameters:
- name- the name of the feature
- configureAction- the configuration for the feature
- Since:
- 5.3
 
- 
disableAutoTargetJvmvoid disableAutoTargetJvm()If this method is called, Gradle will not automatically try to fetch dependencies which have a JVM version compatible with the target compatibility of this module.This should be used whenever the default behavior is not applicable, in particular when for some reason it's not possible to split a module and that this module only has some classes which require dependencies on higher versions. - Since:
- 5.3
 
- 
withJavadocJarvoid withJavadocJar()Adds a taskjavadocJarthat will package the output of thejavadoctask in a JAR with classifierjavadoc.The produced artifact is registered as a documentation variant on the javacomponent and added as a dependency on theassembletask. This means that ifmaven-publishorivy-publishis also applied, the javadoc JAR will be published.If the project already has a task named javadocJarthen no task is created.The publishing of the Javadoc variant can also be disabled using ConfigurationVariantDetails.skip()throughAdhocComponentWithVariants.withVariantsFromConfiguration(Configuration, Action), if it should only be built locally by calling or wiring the ':javadocJar' task.- Since:
- 6.0
 
- 
withSourcesJarvoid withSourcesJar()Adds a tasksourcesJarthat will package the Java sources of the mainSourceSetin a JAR with classifiersources.The produced artifact is registered as a documentation variant on the javacomponent and added as a dependency on theassembletask. This means that ifmaven-publishorivy-publishis also applied, the sources JAR will be published.If the project already has a task named sourcesJarthen no task is created.The publishing of the sources variant can be disabled using ConfigurationVariantDetails.skip()throughAdhocComponentWithVariants.withVariantsFromConfiguration(Configuration, Action), if it should only be built locally by calling or wiring the ':sourcesJar' task.- Since:
- 6.0
 
- 
getModularityModularitySpec getModularity()Configure the module path handling for tasks that have a 'classpath' as input. The module classpath handling defines to determine for each entry if it is passed to Java tools using '-classpath' or '--module-path'.- Since:
- 6.4
 
- 
getToolchainJavaToolchainSpec getToolchain()Gets the project wide toolchain requirements that will be used for tasks requiring a tool from the toolchain (e.g.JavaCompile).Configuring a toolchain cannot be used together with sourceCompatibilityortargetCompatibilityon this extension. Both values will be sourced from the toolchain.- Since:
- 6.7
 
- 
toolchainConfigures the project wide toolchain requirements for tasks that require a tool from the toolchain (e.g.JavaCompile).Configuring a toolchain cannot be used together with sourceCompatibilityortargetCompatibilityon this extension. Both values will be sourced from the toolchain.- Since:
- 6.7
 
- 
consistentResolutionConfigure the dependency resolution consistency for this Java project.- Parameters:
- action- the configuration action
- Since:
- 6.8
 
- 
sourceSetsConfigures the source sets of this project.The given closure is executed to configure the SourceSetContainer. TheSourceSetContaineris passed to the closure as its delegate.See the example below how SourceSet'main' is accessed and how theSourceDirectorySet'java' is configured to exclude some package from compilation.plugins { id 'java' } sourceSets { main { java { exclude 'some/unwanted/package/**' } } }- Parameters:
- closure- The closure to execute.
- Returns:
- NamedDomainObjectContainer<org.gradle.api.tasks.SourceSet>
- Since:
- 7.1
 
- 
getDocsDirDirectoryProperty getDocsDir()Returns a file pointing to the root directory supposed to be used for all docs.- Since:
- 7.1
 
- 
getTestResultsDirDirectoryProperty getTestResultsDir()Returns a file pointing to the root directory of the test results.- Since:
- 7.1
 
- 
getTestReportDirDirectoryProperty getTestReportDir()Returns a file pointing to the root directory to be used for reports.- Since:
- 7.1
 
- 
setSourceCompatibilitySets the source compatibility used for compiling Java sources.- Parameters:
- value- The value for the source compatibility as defined by- JavaVersion.toVersion(Object)
- Since:
- 7.1
 
- 
setTargetCompatibilitySets the target compatibility used for compiling Java sources.- Parameters:
- value- The value for the target compatibility as defined by- JavaVersion.toVersion(Object)
- Since:
- 7.1
 
- 
manifestManifest manifest()Creates a new instance of aManifest.- Since:
- 7.1
 
- 
manifestCreates and configures a new instance of aManifest. The given closure configures the new manifest instance before it is returned.- Parameters:
- closure- The closure to use to configure the manifest.
- Since:
- 7.1
 
- 
manifestCreates and configures a new instance of aManifest.- Parameters:
- action- The action to use to configure the manifest.
- Since:
- 7.1
 
- 
getSourceSetsSourceSetContainer getSourceSets()The source sets container.- Since:
- 7.1
 
- 
getAutoTargetJvmDisabledboolean getAutoTargetJvmDisabled()Tells if automatic JVM targeting is enabled. When disabled, Gradle will not automatically try to get dependencies corresponding to the same (or compatible) level as the target compatibility of this module.- Since:
- 7.1
 
 
-