Package org.gradle.api.plugins

## Interface JavaPluginExtension

-     public interface JavaPluginExtension

  Common configuration for Java based projects. This is added by the `JavaBasePlugin`.
  Since:
    4.10

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `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.
    `ModularitySpec` | `getModularity()` | Configure the module path handling for tasks that have a 'classpath' as input.
    `JavaVersion` | `getSourceCompatibility()` | Returns the source compatibility used for compiling Java sources.
    `JavaVersion` | `getTargetCompatibility()` | Returns the target compatibility used for compiling Java sources.
    `void` | `registerFeature​(String name, Action<? super FeatureSpec> configureAction)` | Registers a feature.
    `void` | `setSourceCompatibility​(JavaVersion value)` | Sets the source compatibility used for compiling Java sources.
    `void` | `setTargetCompatibility​(JavaVersion value)` | Sets the target compatibility used for compiling Java sources.
    `void` | `withJavadocJar()` | Adds a task `javadocJar` that will package the output of the `javadoc` task in a JAR with classifier `javadoc`.
    `void` | `withSourcesJar()` | Adds a task `sourcesJar` that will package the Java sources of the main `SourceSet` in a JAR with classifier `sources`.

- - ### Method Detail

    - #### getSourceCompatibility

          JavaVersion getSourceCompatibility()

      Returns the source compatibility used for compiling Java sources.

    - #### setSourceCompatibility

          void setSourceCompatibility​(JavaVersion value)

      Sets the source compatibility used for compiling Java sources.
      Parameters:
        `value` - The value for the source compatibility

    - #### getTargetCompatibility

          JavaVersion getTargetCompatibility()

      Returns the target compatibility used for compiling Java sources.

    - #### setTargetCompatibility

          void setTargetCompatibility​(JavaVersion value)

      Sets the target compatibility used for compiling Java sources.
      Parameters:
        `value` - The value for the target compatibility

    - #### registerFeature

          void registerFeature​(String name,
                               Action<? super FeatureSpec> configureAction)

      Registers a feature.
      Parameters:
        `name` - the name of the feature
        `configureAction` - the configuration for the feature
      Since:
        5.3

    - #### disableAutoTargetJvm

          void 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

    - #### withJavadocJar

          @Incubating
          void withJavadocJar()

      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(Configuration, Action)`, if it should only be built locally by calling or wiring the ':javadocJar' task.

      Since:
        6.0

    - #### withSourcesJar

          @Incubating
          void withSourcesJar()

      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(Configuration, Action)`, if it should only be built locally by calling or wiring the ':sourcesJar' task.

      Since:
        6.0

    - #### getModularity

          @Incubating
          ModularitySpec 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