Reputation: 1058
This seems like it should be easy but I can't find any documentation. I'd like a Gradle command to generate sources, the Gradle twin of mvn clean generate-sources
if you will.
Thanks in advance!
EDIT: I am not talking about generating a sources jar but rather generating sources to be used in the build. I.e. using Kapt, JAXB, etc.
Upvotes: 1
Views: 586
Reputation: 1884
Put this in your build.gradle.kts
:
...
java {
withSourcesJar()
}
Then a jar named with xxx-sources.jar
should appear in the folder ./build/libs/
after build. You will also see the related task in Gradle:
$ ./gradlew build --dry-run
:app:compileJava SKIPPED
:app:processResources SKIPPED
:app:classes SKIPPED
:app:jar SKIPPED
:app:startScripts SKIPPED
:app:distTar SKIPPED
:app:distZip SKIPPED
:app:sourcesJar SKIPPED <---
:app:assemble SKIPPED
:app:compileTestJava SKIPPED
:app:processTestResources SKIPPED
:app:testClasses SKIPPED
:app:test SKIPPED
:app:check SKIPPED
:app:build SKIPPED
BUILD SUCCESSFUL in 1s
Upvotes: 3