HaMMeReD
HaMMeReD

Reputation: 2462

Can not publish Java project to Maven via BinTray with Gradle

I have a simple project I'm trying to publish to Maven via BinTray, but have been getting an error.

I have followed a guide to publish to bintray, and appear to have BinTray all set up, as well as access to Sonatype. Signing/etc, all appears to be good.

When I run "./gradlew bintrayUpload" I get an error, but the artifacts do show up on bintray. However I get various POM errors.

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 project is https://github.com/ahammer/UsedUtil

build.gradle file is

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 = '[email protected]'

    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'

After publishing I get the error, however in BinTray it registers the upload. When I click add to JCenter however I get another error "- Add a POM file to the latest version of your package."

Upvotes: 1

Views: 1189

Answers (1)

HaMMeReD
HaMMeReD

Reputation: 2462

Instead of using the 3rd party script and out of date plugin, I followed the guide here https://github.com/bintray/gradle-bintray-plugin

This generated a proper pom file and published to bintray and made my package compatible with jcenter.

For a working build.gradle, you can look at my github for the working version.

Upvotes: 1

Related Questions