[英]Deploying to bintray from Maven fails
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. 根据发布版本,我使用Github,Bintray和maven-release-plugin (由Andreas Veithen撰写的博客文章)为Java项目设置了maven构建。
My pom
version is 1.0.2-SNAPSHOT, and I've created the respective version 1.0.2
in my bintray package. 我的
pom
版本是1.0.2-SNAPSHOT,并且我在bintray包中创建了相应的1.0.2
版本。 I perform mvn -Prelease clean install
, no problems. 我执行
mvn -Prelease clean install
,没有问题。 I perform mvn release:prepare
, no problems. 我执行
mvn release:prepare
,没有问题。 But when I perform mvn release:perform
, the build breaks with the error message below. 但是,当我执行
mvn release:perform
,构建会因以下错误消息而中断。
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 ? 我注意到该发行插件正在尝试上传SNAPSHOT ,当然在Bintray上应该没有这个位置了……我以为它会尝试部署1.0.2吗? How can I convince maven to upload the correct artifact, or is there anything wrong with my set up?
如何说服Maven上传正确的工件,或者我的设置有什么问题?
Below are the parts of the POM that I think are relevant, the complete POM is at pastebin . 以下是我认为相关的POM部分,完整的POM在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>
You'll have to post your pom in order to understand what's wrong with your maven release plugin configuration. 您必须发布pom才能了解maven版本插件配置的问题。
Also consider this: You can use oss.jfrog.org to host your snapshots and convert to releases automatically during the push to Bintray. 还请考虑以下事项:您可以使用oss.jfrog.org 托管快照,并在推送到Bintray期间自动将其转换为发行版。
During the maven mvn release:perform
step, the file should be transfered to: 在maven
mvn release:perform
步骤中,应将文件传输到:
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: 这就是Bintray正确返回的原因:
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. 将maven-release-plugin从(my)v2.2.2升级到当前最新的v2.5,为我修复了该问题。 After the upgrade, the
mvn release:prepare
step behave differently. 升级后,
mvn release:prepare
步骤的行为会有所不同。
As mentionned by @vorburger in the comment, if (using maven-deploy-plugin:2.7) Bintray returns: 正如@vorburger在评论中提到的那样,如果(使用maven-deploy-plugin:2.7)Bintray返回:
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
: 然后,“ just”意味着您在
settings.xml
的<server>
没有用户名或密码错误:
<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). matching-id
值应与pom.xml
文件(在<distributionManagement>
>> <repository>
部分中)定义的值相同。
The bintray-api-key
value can be generated in the API Key section of the Bintray profile settings . 可以在Bintray配置文件设置的“ API密钥”部分中生成
bintray-api-key
值。
mvn deploy
for to perform a release mvn deploy
执行发布 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). 由于错误,我最初尝试了
mvn deploy
(试图推送*-SNAPSHOT
),而不是mvn release:prepare
+ mvn release:perform
(可以正确创建并推送版本)。
I had the same problem. 我有同样的问题。 Downgrading the maven-release-plugin to version 2.4 solved the issue for me.
将maven-release-plugin降级到2.4版对我来说解决了这个问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.