Gradle maven发布不适用于第一个版本

时间:2015-02-04 05:27:06

标签: java maven groovy gradle

使用包含以下内容的build.gradle文件:

apply plugin: 'java'
apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            snapshotRepository (url: mavenSnapshotRepoUrl)
            repository (url: mavenRepoUrl) {
               authentication (userName: mavenRepoUsername, password: mavenRepoPassword)
            }
            pom {
                //groupId = project.group
                artifactId = 'myapp'
                //version = project.version
            }
        }
    }
}

当我运行命令uploadArchives时,我收到以下错误:

$ gradlew uploadArchives
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:uploadArchives FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':uploadArchives'.
> Could not publish configuration 'archives'
   > Error deploying artifact 'mycompany:myapp:jar': Error retrieving 
    previous build number for artifact 'mycompany:myapp:jar': repository 
    metadata for: 'snapshot mycompany:myapp:0.0.
    1-SNAPSHOT' could not be retrieved from repository: remote due to an 
    error: Authorization failed: Access denied to: http://myserver\
    /repository/snapshots/mycompany/myapp/0.0.1-SNAPSHOT/maven-metadata.xml

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

我已经检查了我的用户名和密码。是否有我缺少的东西,或者这是初次发布的常用方法吗?

1 个答案:

答案 0 :(得分:0)

我执行

时出现了非常类似的错误消息
$ gradle uploadArchives

在我的Mac Book上。我的Mac坐在该工作的代理服务器后面。我有一个远程公共Artifactory存储库服务器,我尝试上传我的jar。

在过去的几个月里,由于代理干预,我遇到了很多问题。我认为这个错误必须与Proxy有关。

我转移到AWS EC2实例。我在ec2实例上克隆了我的gradle项目,并执行了相同的操作:

$ gradle uploadArchives

成功!

代码中无需更改。

更简单的HTTP连接路由让我感到高兴。