Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure Gradle to publish sources and javadoc

Tags:

java

gradle

How do I configure Gradle to publish sources and javadoc jars to a repository?

like image 556
Paolo Fulgoni Avatar asked Feb 20 '14 09:02

Paolo Fulgoni


People also ask

What is Javadoc in Gradle?

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 }

What is groupId and artifactId in Gradle?

In Gradle, the groupId is known just as group , the artifactId is known as name , and the version is identically version .


1 Answers

Solution as of Gradle 6.0

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:

  • on the two new methods
  • on the maven-publish plugin
  • on the ivy-publish plugin
like image 62
Chriki Avatar answered Oct 15 '22 00:10

Chriki