You can do the same with maven by adding the following to your
<repositories> <repository> <id>central</id> <name>bintray</name> <url>http://jcenter.bintray.com</url> </repository> </repositories>
But we want to make it even easier for maven users by publishing our artifacts to the Maven Central repository which maven uses by default.
The easiest way to publish to Maven Central is synchronization via bintray. The setup process is not trivial, so I want to share my experience.
- Apply for a repository for your organisation (in our case:
- Optionally generate a gpg key without password and upload it to bintray. As an alternative you can also use bintray’s key.
- Configure your bintray maven repository to automatically sign uploaded files
- Make sure your project conforms to Maven Central’s quality requirements:
pom.xmlmust contain information about the project license and developers (elements
- Publish the source code by adding this to your
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <version>3.0.1</version> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin>
- Publish javadoc by adding this to
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-javadoc-plugin</artifactId> <version>3.0.1</version> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin>
- Now you can publish your artifacts to JCenter as usual via mvn deploy. Don’t forget to increment your version number in
- The last step is to synchronize the artifacts by clicking the “Sync” button in the “Maven Central” tab in bintray. If everything was OK after some time you should see the message “Successfully synced and closed repo”.
Then it will take some time (in my case around 40 minutes) until your packages are shown in Maven Central and you can search for it. And then it will take up to two hours until you can find them at search.maven.org.