How do I configure Gradle to publish sources and javadoc jars to a repository?
Javadoc. Generates HTML API documentation for Java classes. If you create your own Javadoc tasks remember to specify the 'source' property! Without source the Javadoc task will not create any documentation. Example: plugins { id 'java' } task myJavadocs(type: Javadoc) { source = sourceSets.main.allJava }
In Gradle, the groupId is known just as group , the artifactId is known as name , and the version is identically version .
Here’s the somewhat minimal configuration you can use if you’re on Gradle 6.0 or later; note the newly introduced withSourcesJar()
and withJavadocJar()
methods:
plugins { id 'java' id 'maven-publish' } group = 'com.example' java { withSourcesJar() withJavadocJar() } publishing { repositories { maven { url = 'file:///tmp/my-repo' } } publications { myJava(MavenPublication) { from components.java } } }
Of course, you can also use the ivy-publish
plugin instead of maven-publish
.
See also the Gradle docs:
maven-publish
plugin ivy-publish
plugin If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With