gradle
8.5

# withSourcesJar

abstract fun withSourcesJar()(source)

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.