Since Github disabled the downloads, we need to use a new service (like Bintray.com) for publishing our binaries. For our usecase I need to build a package (using appassembler-maven-plugin), then zip and tar.gz this build and deploy it to bintray.
It would be nice if a nightly builds will be shipped by travis and releases from hand with the mvn release plugin.
Currently the pom looks like this:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>myproject</groupId>
<artifactId>myproject</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<scm>
<url>https://github.com/d0x/fromGithubToBintray</url>
<connection>scm:git:git://github.com/d0x/fromGithubToBintray.git</connection>
<developerConnection>scm:git:[email protected]:d0x/fromGithubToBintray.git</developerConnection>
</scm>
<developers>
<developer>
<name>Christian Schneider</name>
<url>https://github.com/d0x</url>
<id>d0x</id>
</developer>
</developers>
<!-- <distributionManagement> -->
<!-- <repository> -->
<!-- <id>bintray</id> -->
<!-- <url>https://api.bintray.com/maven/d0x/fromGithubToBintray/downloads</url> -->
<!-- </repository> -->
<!-- </distributionManagement> -->
<properties>
<mainClass>fromGithubToBintray.Main</mainClass>
<java-version>1.7</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<!-- ... -->
</dependencies>
<build>
<plugins>
<!-- To build a clean binary pacakge to distribute -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>appassembler-maven-plugin</artifactId>
<version>1.4</version>
<configuration>
<programs>
<program>
<mainClass>${mainClass}</mainClass>
<name>fromGithubToBintray</name>
</program>
</programs>
<extraJvmArguments>-Djava.awt.headless=true</extraJvmArguments>
</configuration>
</plugin>
<!-- To specify the Java Version -->
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
<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>
</project>
How to tune the pom file to do that?
Reproduce:
I uploaded the small example to github: https://github.com/d0x/fromGithubToBintray
To exectue it do the following:
This should print You did it!. Now the goal is to upload compress and upload this appassembler folder to bintray.
Research done:
The problem is that Bintray does not support SNAPSHOTs (Bintray is for releases only). What you need is an Artifactory+Bintray combo, that deploys snapshots to Artifactory, and once in a while (when you deside), releases a 'production-ready' version to Bintray.
Depending on the nature of your project you might be qualified to a free account on oss.jfrog.org. The requirement is that your deliverable is an open-source library/product, which is included in JCenter.
Pushing from Artifactory to Bintray is a really simple process, you can perform it just by clicking a button in Artifactory UI or by performing a REST call. Just remember - it must be a release, not a SNAPSHOT.
There are number of ways to convert a SNAPSHOT to release, which include changing versions in POM by hand, Maven Release Plugin, and others. When you use oss.jfrog.org as your Artifactory server, it includes a special plugin, which converts SHAPSHOTs to releases and deploys to Bintray in one go.
I think there are 2 ways to deploy your zip/tar.gz files to bintray.com.
1. Upload over CI
You can upload generic files to bintrac.com with curl.
curl -T <FILE.EXT> -u$USER:<API_KEY> https://api.bintray.com/content/$USER/generic/<UR_COOL_PACKAGE_NAME>/<VERSION_NAME>/<FILE_TARGET_PATH>
You can build your project over maven with a CI/travis and upload a specified file with curl. It should be possible with travis. See here
2. Deploy with Maven
With maven you can deploy a specified file like a *.zip with mvn deploy:deploy-file. Maybe this is a solution for you?
EDIT after answer
To create a *.zip archive you can use the maven-assembly-plugin
1. Add maven-assembly-plugin to pom
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptor>src/main/assembly/bin.xml</descriptor>
</configuration>
</plugin>
2. Create configuration file
I created for you a small example. it will compress the bin folder from your appassembler target.
<?xml version="1.0" encoding="UTF-8"?>
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>target/appassembler/bin</directory>
<outputDirectory></outputDirectory>
</fileSet>
</fileSets>
</assembly>
3. Execute maven
Command: mvn clean appassembler:assemble package
4. Upload generic file
To upload your generic file with maven. You should have a look to exec-maven-plugin or you use the mvn deploy:deploy-file plugin. If you want use this, it should look like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.6</version>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<repositoryId>release</repositoryId>
<packaging>zip</packaging>
<generatePom>false</generatePom>
<url>http://repository-url</url>
<artifactId>${project.artifactId}</artifactId>
<groupId>${project.groupId}</groupId>
<version>${project.version}</version>
<file>target/filename.zip</file>
</configuration>
</plugin>
...
<distributionManagement>
<repository>
<id>releases</id>
<name>My Artifactory-... server</name>
<url>http://url-to-repository</url>
</repository>
</distributionManagement>
In my case, my settings.xml from maven looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>my-user</username>
<password>my-password</password>
<id>releases</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<id>releases</id>
<name>Name</name>
<url>http://serverurl</url>
</repository>
</repositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
if you execute now mvn clean appassembler:assemble package and then mvn deploy:deploy-file you will create a archive and upload it to your maven repository.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With