Table of Contents
| API Documentation: | JavaPluginExtension |
|---|
Common configuration for Java based projects. This is added by the JavaBasePlugin.
| Property | Description |
sourceCompatibility | The source compatibility used for compiling Java sources. |
targetCompatibility | The target compatibility used for compiling Java sources. |
toolchain | Incubating Gets the project wide toolchain requirements that will be used for tasks requiring a tool from the toolchain (e.g. |
| Method | Description |
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. |
registerFeature(name, configureAction) | Registers a feature. |
toolchain(action) | Incubating Configures the project wide toolchain requirements for tasks that require a tool from the toolchain (e.g. |
withJavadocJar() | Incubating Adds a task |
withSourcesJar() | Incubating Adds a task |
JavaVersion sourceCompatibility
The source compatibility used for compiling Java sources.
- Default with
javaplugin: - Value of the current used JVM (e.g.
JavaVersion.JAVA_1_6on a 1.6 JVM).
JavaVersion targetCompatibility
The target compatibility used for compiling Java sources.
- Default with
javaplugin: project.sourceCompatibility
JavaToolchainSpec toolchain (read-only)
Note: This property is incubating and may change in a future version of Gradle.
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 sourceCompatibility or targetCompatibility on this extension.
Both values will be sourced from the toolchain.
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.
void registerFeature(String name, Action<? super FeatureSpec> configureAction)
Action<? super FeatureSpec>Registers a feature.
JavaToolchainSpec toolchain(Action<? super JavaToolchainSpec> action)
Action<? super JavaToolchainSpec>Note: This method is incubating and may change in a future version of Gradle.
Configures 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 sourceCompatibility or targetCompatibility on this extension.
Both values will be sourced from the toolchain.
Note: This method is incubating and may change in a future version of Gradle.
Adds a task javadocJar that will package the output of the javadoc task in a JAR with classifier javadoc.
The produced artifact is registered as a documentation variant on the java component and added as a dependency on the assemble task.
This means that if maven-publish or ivy-publish is also applied, the javadoc JAR will be published.
If the project already has a task named javadocJar then no task is created.
The publishing of the Javadoc variant can also be disabled using ConfigurationVariantDetails.skip()
through AdhocComponentWithVariants.withVariantsFromConfiguration(org.gradle.api.artifacts.Configuration, org.gradle.api.Action),
if it should only be built locally by calling or wiring the ':javadocJar' task.
Note: This method is incubating and may change in a future version of Gradle.
Adds a task sourcesJar that will package the Java sources of the main SourceSet in a JAR with classifier sources.
The produced artifact is registered as a documentation variant on the java component and added as a dependency on the assemble task.
This means that if maven-publish or ivy-publish is also applied, the sources JAR will be published.
If the project already has a task named sourcesJar then no task is created.
The publishing of the sources variant can be disabled using ConfigurationVariantDetails.skip()
through AdhocComponentWithVariants.withVariantsFromConfiguration(org.gradle.api.artifacts.Configuration, org.gradle.api.Action),
if it should only be built locally by calling or wiring the ':sourcesJar' task.