无法通过BinTray使用Gradle将Java项目发布到Maven

时间:2016-07-03 12:40:45

标签: java maven gradle artifact bintray

我有一个简单的项目,我试图通过BinTray发布到Maven,但是一直出错。

我已经按照指南发布到bintray,似乎已经设置了BinTray,以及访问Sonatype。签名/等,似乎都很好。

当我运行“./gradlew bintrayUpload”时,我收到一个错误,但工件确实出现在bintray上。但是我得到了各种POM错误。

adams-MBP:UsedUtil adamhammer2$ ./gradlew clean install
:clean
:compileJava
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: /Users/adamhammer2/git/UsedUtil/src/main/java/com/mysaasa/usedutil/CallKeyGenerator.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 warning
:processResources UP-TO-DATE
:classes
:jar
:javadoc
:javadocJar
:sourcesJar
:install

BUILD SUCCESSFUL

Total time: 7.233 secs
adams-MBP:UsedUtil adamhammer2$ ./gradlew bintrayUpload
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:jar UP-TO-DATE
:javadoc UP-TO-DATE
:javadocJar UP-TO-DATE
:sourcesJar UP-TO-DATE
:install
:bintrayUpload FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':bintrayUpload'.
> Could not upload to 'https://api.bintray.com/content/adamhammer/maven/used-util/0.9.1/com/mysaasa/used_util/UsedUtil/0.9.1/UsedUtil-0.9.1.pom': HTTP/1.1 400 Bad Request [message:Unable to upload files: Maven group, artifact or version defined in the pom file do not match the file path 'com/mysaasa/used_util/UsedUtil/0.9.1/UsedUtil-0.9.1.pom']

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

BUILD FAILED

Total time: 12.923 secs

Github项目是https://github.com/ahammer/UsedUtil

build.gradle文件是

buildscript {
    repositories {
        mavenCentral()
        jcenter()
    }
    dependencies {
        classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.4'
        classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
    }
}

apply plugin: 'java'

sourceCompatibility = 1.7

repositories {
    mavenCentral()
}



dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.+'
}

ext {
    bintrayRepo = 'maven'
    bintrayName = 'used-util'

    publishedGroupId = 'com.mysaasa.used_util'
    libraryName = 'UsedUtil'
    artifact = 'usedutil'

    libraryDescription = 'A Library for tracking usage in java projects'

    siteUrl = 'http://ahammer.github.io/UsedUtil'
    gitUrl = 'https://github.com/ahammer/UsedUtil.git'

    libraryVersion = '0.9.1'

    developerId = 'adamhammer'
    developerName = 'Adam Hammer'
    developerEmail = 'adamhammer2@gmail.com'

    licenseName = 'The Apache Software License, Version 2.0'
    licenseUrl = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
    allLicenses = ["Apache-2.0"]
}

apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/installv1.gradle'
apply from: 'https://raw.githubusercontent.com/nuuneoi/JCenter/master/bintrayv1.gradle'

发布后我得到错误,但是在BinTray中它注册了上传。当我点击添加到JCenter但是我得到另一个错误“ - 将POM文件添加到包的最新版本。”

1 个答案:

答案 0 :(得分:0)

我没有使用第三方脚本和过时插件,而是按照指南进行操作 这里https://github.com/bintray/gradle-bintray-plugin

这会生成一个合适的pom文件并发布到bintray并使我的包与jcenter兼容。

对于正在运行的build.gradle,您可以查看我的github以获取工作版本。