# withSourcesJar

abstract fun withSourcesJar()

Enables generating a sources artifact for the main feature of this project. If no components with a main feature are defined for this project, this has no effect.

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 skip through withVariantsFromConfiguration, if it should only be built locally by calling or wiring the ':sourcesJar' task.

#### Since

6.0