How JRebirth deploys to JCenter and Maven Central

This post will describe briefly how we are managing the release of all JRebirth artifacts by using Maven Build, Jenkins, Artifactory, Bintray/JCenter and Nexus.

Reminder

All JRebirth artifacts are deployed to several repositories as explained into the official documentation page : Installation

As you probably know, JRebirth is built using Maven tool, really convenient to package binaries, javadoc and sources jar but also to make and deploy the jrebirth website with syntax highlighting (thx to doxia include macro). It allows to break the build if a piece of code used into documentation is missing (ie: after some refactoring changes).

Repository Strategy

JRebirth is pushed by our Continuous Integration Server on several repositories to be available everywhere. (it uses a parameterized build that let to choose a git tag to build and Maven profiles used)

ci.jrebirth.org |--> repo.jrebirth.org (Local Artifactory)
                |--> oss.jfrog.org (OSS Artifactory)
                |--> bintray.com --> JCenter --> oss.sonatype.org --> Maven Central

 Maven profiles

To select the target repository, I have defined a parameterized section for distribution management into the JRebirth Organization ‘super’ parent pom.

<distributionManagement>
	<repository>
		<id>${repositoryId}</id>
		<name>${repositoryName}</name>
		<url>${repositoryUrl}</url>
	</repository>
	<snapshotRepository>
		<id>${snapshotRepositoryId}</id>
		<name>${snapshotRepositoryName}</name>
		<url>${snapshotRepositoryUrl}</url>
	</snapshotRepository>
</distributionManagement>

And then I created 3 profiles that can be activated to choose the right target repository

<profile>
	<id>OJO</id>
	<activation>
		<activeByDefault>true</activeByDefault>
	</activation>
	<properties>
		<!-- Release repository -->
		<repositoryId>oss-jfrog-artifactory</repositoryId>
		<repositoryName>oss-jfrog-artifactory-releases</repositoryName>
		<repositoryUrl>http://oss.jfrog.org/artifactory/oss-release-local</repositoryUrl>
		<!-- Snapshot repository -->
		<snapshotRepositoryId>oss-jfrog-artifactory</snapshotRepositoryId>
		<snapshotRepositoryName>oss-jfrog-artifactory-snapshots</snapshotRepositoryName>
		<snapshotRepositoryUrl>http://oss.jfrog.org/artifactory/oss-snapshot-local</snapshotRepositoryUrl>
	</properties>
</profile>

<!-- JCenter repository for release and central sync -->
<profile>
	<id>Bintray</id>
	<properties>
		<!-- Release repository -->
		<repositoryId>bintray-jrebirth-JRebirth-Organization</repositoryId>
		<repositoryName>jrebirth-JRebirth-Organization</repositoryName>
		<repositoryUrl>https://api.bintray.com/maven/jrebirth/JRebirth/Organization/</repositoryUrl>
		<!-- Snapshot repository -->
		<snapshotRepositoryId>bintray-jrebirth-JRebirth-Organization</snapshotRepositoryId>
		<snapshotRepositoryName>jrebirth-JRebirth-Organization</snapshotRepositoryName>
		<snapshotRepositoryUrl>https://api.bintray.com/maven/jrebirth/JRebirth/Organization/</snapshotRepositoryUrl>
	</properties>
</profile>

<!-- Private repository for own tests & development -->
<profile>
	<id>JRebirth</id>
	<properties>
		<!-- Release repository -->
		<repositoryId>JRebirth-Release</repositoryId>
		<repositoryName>JRebirth Releases Repository</repositoryName>
		<repositoryUrl>http://repo.jrebirth.org/jrebirth-release-local</repositoryUrl>
		<!-- Snapshot repository -->
		<snapshotRepositoryId>JRebirth-Snapshot</snapshotRepositoryId>
		<snapshotRepositoryName>JRebirth Snasphots Repository</snapshotRepositoryName>
		<snapshotRepositoryUrl>http://repo.jrebirth.org/jrebirth-snapshot-local</snapshotRepositoryUrl>
	</properties>
</profile>

Note:

The Organization Pom is pushed to jrebirth/JRebirth/Organization bintray’s package (bintray’s organization / Bintray’s repository / Bintray’s Package); but the JRebirth AF is pushed to  jrebirth/JRebirth/JRebirthAF, so I have overriden this part into JRebirthAF parent pom:

<profiles>
	<!-- Override Bintray profile to use another Bintray Package -->
	<profile>
		<id>Bintray</id>
		<properties>
			<!-- Release repository -->
			<repositoryId>bintray-jrebirth-JRebirth-JRebirthAF</repositoryId>
			<repositoryName>jrebirth-JRebirth-JRebirthAF</repositoryName>
			<repositoryUrl>https://api.bintray.com/maven/jrebirth/JRebirth/JRebirthAF/</repositoryUrl>
			<!-- Snapshot repository -->
			<snapshotRepositoryId>bintray-jrebirth-JRebirth-JRebirthAF</snapshotRepositoryId>
			<snapshotRepositoryName>jrebirth-JRebirth-JRebirthAF</snapshotRepositoryName>
			<snapshotRepositoryUrl>https://api.bintray.com/maven/jrebirth/JRebirth/JRebirthAF/</snapshotRepositoryUrl>
		</properties>
	</profile>
</profiles>

Push to Bintray

Now we can call: maven clean deploy -P Bintray,GPG to push artifacts to Bintray, when the build has succeeded open your Bintray Package, you will see a notice message indicating that some items can be added to this package.

BintrayJust accept them by clicking on Publish, and you can use the File tab pane tocheck that all files are OK.

Bintray2

A this point, your binaries are available within Bintray !!!

You shall ask to Bintray support to permanently sync your package into JCenter, this should be done only once and will take some hours to let them verify your owner rights on binaries published.

JCenterWhen they accept this automatic synchronization, your binaries will be automatically available on JCenter, also for future files

But what is JCenter ? In few words, it’s the best alternative to Maven Central, because it’s a superset of it !

According to bintray’s web site:

JCenter is the place to find and share popular Apache Maven packages for use by Maven, Gradle, Ivy, SBT, etc.
For the most comprehensive collection of artifacts, point your Maven at: http://jcenter.bintray.com
Want to distribute your own packages through JCenter? You can link your package by clicking the “Include My Package” button.
And if you’re into legacy, you can even synchronize your packages directly to Maven Central.

You can find more information here : http://blog.bintray.com/2014/02/11/bintray-as-pain-free-gateway-to-maven-central/

Legacy Sync !

Let’s send our binaries to Maven Central, the largest ‘legacy’ repository for java binaries, use the right tab pane.
Then use your login/password asked on sonatype’s JIRA. (http://central.sonatype.org/pages/ossrh-guide.html) and click Sync button.

Bintray3Wait a moment and carefully read the Sync Status message, if there isn’t any error you can jump to next step.

Bintray4

Release on Central

Previous steps only send all files to staging area into oss.sonatype.org repository, the antechamber of Maven Central. So you have to perform some other steps to really release them.

Tip (Thanks to jbaruch for the reminder):

All these steps could be skipped if you check the item “Close and release repository when done”. But the first time you should perform it manually to check what goes wrong (even if errors are displayed within Bintray page). You can also modify staged files, in example to remove some files.

 

Log in to Sonatype repo, and open staging repositories page.
Find the repository created by the Bintray synchronization (for us it was orgjrebirth-1014) and close it !

CentralA confirmation popup will be displayed, just validate it and check the close logs.

Central2Then release the staged repository

Central3Again check the release logs, first time there are often error like missing GPG signature or missing javadoc or source jars (you can browse JRebirth pom to find how it was configured). You can also refer to the sonatype how-to web page to fix these errors.

Before 8.0.2 I had to remove all showcases modules because validation of Maven submodules was failing due to an old Maven issue, fortunately it was fixed and no more manual steps are required.

Central4

Great ! your repository is now released, you can drop it and wait some hours to see your files available into Maven Central.

searchmaven

 

 

 

Leave a Reply