1

I've set up the maven build for a Java project according to Publishing releases using Github, Bintray and maven-release-plugin , a blog post by Andreas Veithen.

My pom version is 1.0.2-SNAPSHOT, and I've created the respective version 1.0.2 in my bintray package. I perform mvn -Prelease clean install, no problems. I perform mvn release:prepare, no problems. But when I perform mvn release:perform, the build breaks with the error message below.

Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy 
(default-deploy) on project [PROJECT]: Failed to deploy artifacts: Could not 
transfer artifact my.project:test:jar:1.0.2-20140408.154954-1 from/to bintray-
user-maven-package (https://api.bintray.com/maven/user/maven/package): Failed to 
transfer file: https://api.bintray.com/maven/user/maven/package/my/project/test/
1.0.2-SNAPSHOT/test-1.0.2-20140408.154954-1.jar. Return code is: 400, 
ReasonPhrase: Bad Request. -> [Help 1]

I'm noticing that the release plugin is trying to upload the SNAPSHOT, and of course this should have no place on bintray... I'd have thought that it would try to deploy 1.0.2? How can I convince maven to upload the correct artifact, or is there anything wrong with my set up?

Below are the parts of the POM that I think are relevant, the complete POM is at pastebin.

<modelVersion>4.0.0</modelVersion>
<groupId>my.tool</groupId>
<artifactId>util</artifactId>
<packaging>jar</packaging>
<version>1.0.2-SNAPSHOT</version>

<scm>
  <connection>scm:git:https://github.com/user/package.git</connection>
  <developerConnection>scm:git:git@github.com:user/package.git</developerConnection>
  <url>https://github.com/user/package</url>
  <tag>HEAD</tag>
</scm>

<distributionManagement>
  <repository>
    <id>bintray-user-maven-package</id>
    <name>user-maven-package</name>
    <url>https://api.bintray.com/maven/user/maven/package</url>
  </repository>
</distributionManagement>

<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>

<build>
 <defaultGoal>install</defaultGoal>
 <plugins>
      <plugin>
           <groupId>org.apache.maven.plugins</groupId>
           <artifactId>maven-compiler-plugin</artifactId>
           <version>3.1</version>
           <configuration>
                <source>1.7</source>
                <target>1.7</target>
           </configuration>
      </plugin>
      <plugin>
            <groupId>com.mycila</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <version>2.6</version>
            <configuration>
                <header>${basedir}/src/etc/header.txt</header>
                <includes>
                    <include>src/main/java/**</include>
                    <include>src/test/java/**</include>
                </includes>
            </configuration>
            <executions>
                <execution>
                    <goals>
                        <goal>check</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5</version>
          <configuration>
            <useReleaseProfile>false</useReleaseProfile>
            <releaseProfiles>release</releaseProfiles>
            <autoVersionSubmodules>true</autoVersionSubmodules>
          </configuration>
        </plugin>
  </plugins>
</build>
Andreas Veithen
  • 8,868
  • 3
  • 25
  • 28
s.d
  • 4,017
  • 5
  • 35
  • 65
  • Are you sure you are trying to release 1.0.2 and not 1.0.1? Because I'd expect Maven to try and deploy 1.0.2-SNAPSHOT after the release of 1.0.1. – JBaruch Apr 09 '14 at 10:23
  • @JBaruch: Sorry, I've made a number of hard resets and deleted tags after a couple of failed releases. I've changed the POM version to `1.0.2-SNAPSHOT` again... – s.d Apr 09 '14 at 11:16

3 Answers3

1

You'll have to post your pom in order to understand what's wrong with your maven release plugin configuration.

Also consider this: You can use oss.jfrog.org to host your snapshots and convert to releases automatically during the push to Bintray.

  • Disadvantage - for open-source projects that linked to jcenter only
  • Advantage - everything else :) Free Artifactory instance for development process, integration with any CI server (hosted or cloud), transparent release to Bintray with a single rest API call.
JBaruch
  • 22,610
  • 5
  • 62
  • 90
  • Thanks. Added relevant POM excerpts to the question and put the whole thing up at pastebin. – s.d Apr 09 '14 at 09:11
1

During the maven mvn release:perform step, the file should be transfered to:

https://api.bintray.com/maven/user/maven/package/my/project/test/1.0.2

And not to:

https://api.bintray.com/maven/user/maven/package/my/project/test/1.0.2-SNAPSHOT

This is why Bintray correcly returns:

Return code is: 400, ReasonPhrase: Bad Request.

Upgrading maven-release-plugin from (my) v2.2.2 to currently latest v2.5 fixed it for me. After the upgrade, the mvn release:prepare step behave differently.


Return code is: 401

As mentionned by @vorburger in the comment, if (using maven-deploy-plugin:2.7) Bintray returns:

Return code is: 401, ReasonPhrase: Unauthorized.

Then that 'just' means that you have no or a wrong username and password for the <server> in the settings.xml:

<server>
  <id>{matching-id}</id>
  <username>{bintray-user}</username>
  <password>{bintray-api-key}</password>
</server>

The matching-id value should be the same than the one defined in the pom.xml file (in the <distributionManagement> > <repository> section).

The bintray-api-key value can be generated in the API Key section of the Bintray profile settings.


Do not use mvn deploy for to perform a release

By mistake I originally tried mvn deploy (which attempted to push a *-SNAPSHOT) instead of mvn release:prepare + mvn release:perform (which correctly creates and pushes a release).

Jmini
  • 9,189
  • 2
  • 55
  • 77
vorburger
  • 3,439
  • 32
  • 38
  • PS: If instead of "Return code is: 400, ReasonPhrase: Bad Request." you hit a "Return code is: 401, ReasonPhrase: Unauthorized." from https://api.bintray.com/maven/... (using maven-deploy-plugin:2.7), then that 'just' means that you have no or a wrong username and password for the (with matching ...) in the settings.xml. – vorburger Sep 21 '14 at 09:26
0

I had the same problem. Downgrading the maven-release-plugin to version 2.4 solved the issue for me.

Sebastian Schuth
  • 9,999
  • 1
  • 20
  • 16