Publishing releases using Github, Bintray and maven-release-plugin
Project setup
-
Add an SCM section to your POM so that maven-release-plugin can create a tag during the release process:
<scm> <connection>scm:git:https://github.com/{github-user}/{github-repo}.git</connection> <developerConnection>scm:git:git@github.com:{github-user}/{github-repo}.git</developerConnection> <url>https://github.com/{github-user}/{github-repo}</url> <tag>HEAD</tag> </scm>
The developer connection uses the SSH protocol, so that no password authentication is required. Note that this assumes that you uploaded your public key to Github.
-
Go to the Bintray Web site and create a new package in your repository.
-
Add a distribution management section to your POM with a reference to that package:
<distributionManagement> <repository> <id>bintray</id> <url>https://api.bintray.com/maven/{bintray-user}/{bintray-repo}/{package}</url> </repository> </distributionManagement>
-
Add your Bintray credentials to
settings.xml
. Note that Bintray REST API uses API keys instead of passwords. (Use the API Key section of your profile settings to obtain yourbintray-api-key
):<server> <id>bintray</id> <username>{bintray-user}</username> <password>{bintray-api-key}</password> </server>
-
Add the release plugin to your POM:
<build> <plugins> <plugin> <artifactId>maven-release-plugin</artifactId> <version>2.4.1</version> <configuration> <useReleaseProfile>false</useReleaseProfile> <releaseProfiles>release</releaseProfiles> <autoVersionSubmodules>true</autoVersionSubmodules> </configuration> </plugin> </plugins> </build>
To deploy source and Javadoc JARs for releases, use the following release profile:
<profiles> <profile> <id>release</id> <build> <plugins> <plugin> <artifactId>maven-source-plugin</artifactId> <executions> <execution> <id>attach-sources</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-javadoc-plugin</artifactId> <executions> <execution> <id>attach-javadocs</id> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>
You should validate the release profile by executing it as follows:
mvn -Prelease clean install
Performing a release
-
Go the the Bintray Web site and add a new version for the package.
-
Execute the release process as follows:
mvn release:prepare mvn release:perform
-
Go to the Bintray Web site and publish the new version.
Using the project as dependency
To use your project as a dependency in another project, add the following repository declaration:
<repositories>
<repository>
<id>bintray</id>
<url>http://dl.bintray.com/{bintray-user}/{bintray-repo}</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>