I recently got interested in Spring Social, and as part of my learning path, I tried to integrate their Github module which is still in Incubator mode. Unfortunately, this module seems to have been left behind, and its dependency on the core module uses an old version of it. And since I use the latest version of this core, Maven resolves one version to put in the WEB-INF/lib folder of the WAR package. Unfortunately, it doesn’t work so well at runtime.
The following diagram shows this situation:
I could have excluded the old version from the transitive dependencies, but I’m lazy and Maven doesn’t make it easy (yet). Instead, I decided to just upgrade the Github module to the latest version and install it in my local repository. That proved to be quite easy as there was no incompatibility with the newest version of the core - I even created a pull request. This is the updated situation:
Unfortunately, if I now decide to distribute this version of my application, nobody will be able to neither build nor run it since only I have the "patched" (latest) version of the Github module available in my local repo. I could distribute along the updated sources, but it would mean you would have to build it and install it into your local repo first before using my app.
Bintray to the rescue! Bintray is a binary repository, able to host any kind of binaries: jars, wars, deb, anything. It is hosted online, and free for OpenSource projects, which nicely suits my use-case. This is how I uploaded my artifact on Bintray.
- Create an account
-
Bintray makes it quite easy to create such an account, using of the available authentication providers - Github, Twitter or Google+. Alternatively, one can create an old-style account, with password.
- Create an artifact
-
Once authentified, an artifact needs to be created. Select your default Maven repository, it can be found at https://bintray.com/${username}/maven. Then, click on the big Add New Package button located on the right border. On the opening page, fill in the required information. The package can be named whatever you want, I chose to use the Maven artifact identifier:
spring-social-github
. - Create a version
-
Files can only be added to a version, so that a version need to be created first. On the package detail page, click on the New Version link (second column, first line).
On the opening page, fill in the version name. Note that snapshots are not accepted and this is only checked through the
-SNAPSHOT
suffix. I chose to use1.0.0.BUILD
. - Upload files
-
Once the version is created, files can finally be uploaded. In the top bar, click the Upload Files button. Drag and drop all desired files, of course the main JAR and the POM, but it can also include source and javadoc JARs. Notice the Target Repository Path field: it should be set to the logical path to the Maven artifact, including
groupId
,artifactId
andversion
separated by slashes. For example, my use-case should resolve toorg/springframework/social/spring-social-github/1.0.0.BUILD
. Note that instead of filling this field, you can wait for the files to be uploaded as Bintray will detect this upload, analyze the POM and propose to set it automatically: if this fits - and it probably does, just accept the proposal. - Publish
-
Uploading files is not enough, as those files are temporary until publication. A big notice warns about it: just click on the Publish link located on the right border.
At this point, you need only to add the Bintray repository in the POM.
<repositories>
<repository>
<id>bintray</id>
<url>http://dl.bintray.com/nfrankel/maven</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>