bintray / gradle-bintray-plugin

Apache License 2.0
1.28k stars 197 forks source link

400 exception with failed upload of POM file only? #88

Open reaperdtme opened 9 years ago

reaperdtme commented 9 years ago

build.grade

apply plugin: 'com.android.library'

ext {
    bintrayRepo = 'maven'
    bintrayName = 'appswitcher'
    bintrayOrg = 'inmarket'
    versionName = "1.0.0"

    publishedGroupId = 'com.inmarket'
    libraryName = 'appswitcher'
    artifact = 'appswitcher'

    libraryDescription = 'App switching library for Android'

    libraryVersion = '1.0.0'

    developerId = 'zaidd'
    developerName = 'Zaid Daghestani'
    developerEmail = 'zdaghestani@inmarket.com'

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

android {
    compileSdkVersion 21
    buildToolsVersion "23.0.1"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 8
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

dependencies {
    compile "com.android.support:support-v4:18.0.+"
}

//bintray init

apply plugin: 'com.github.dcendents.android-maven'

group = publishedGroupId                               // Maven Group ID for the artifact

install {
    repositories.mavenInstaller {
        // This generates POM.xml with proper parameters
        pom {
            project {
                packaging 'aar'
                groupId publishedGroupId
                artifactId artifact

                // Add your description here
                name libraryName
                description libraryDescription

                // Set your license
                licenses {
                    license {
                        name licenseName
                        url licenseUrl
                    }
                }
                developers {
                    developer {
                        id developerId
                        name developerName
                        email developerEmail
                    }
                }
            }
        }
    }
}

// bintray do

apply plugin: 'com.jfrog.bintray'

version = libraryVersion

task sourcesJar(type: Jar) {
    from android.sourceSets.main.java.srcDirs
    classifier = 'sources'
}

task javadoc(type: Javadoc) {
    description "app javadocs"
    source = android.libraryVariants["release"].javaCompile.source
    ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
    classpath = files(android.libraryVariants["release"].javaCompile.classpath.files) + files(ext.androidJar)
    options.links("http://docs.oracle.com/javase/7/docs/api/");
    options.links("http://d.android.com/reference/");
    exclude '**/BuildConfig.java'
    exclude '**/R.java'
}

task javadocJar(type: Jar, dependsOn: javadoc) {
    classifier = 'javadoc'
    from javadoc.destinationDir
}

artifacts {
    archives javadocJar
    archives sourcesJar
}

// Bintray
Properties properties = new Properties()
properties.load(project.rootProject.file('local.properties').newDataInputStream())

bintray {
    user = properties.getProperty("bintray.user")
    key = properties.getProperty("bintray.apikey")

    configurations = ['archives']
    pkg {
        repo = bintrayRepo
        name = bintrayName
        userOrg = bintrayOrg
        desc = libraryDescription
        licenses = allLicenses
        publish = true
        publicDownloadNumbers = true
        version {
            name = bintrayName
            desc = libraryDescription
        }
    }
}

generated pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.inmarket</groupId>
  <artifactId>appswitcher</artifactId>
  <version>1.0.0</version>
  <packaging>aar</packaging>
  <name>appswitcher</name>
  <description>App switching library for Android</description>
  <licenses>
    <license>
      <name>The Apache Software License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>
  <developers>
    <developer>
      <id>zaidd</id>
      <name>Zaid Daghestani</name>
      <email>zdaghestani@inmarket.com</email>
    </developer>
  </developers>
  <dependencies>
    <dependency>
      <groupId>com.android.support</groupId>
      <artifactId>support-v4</artifactId>
      <version>18.0.+</version>
      <scope>compile</scope>
    </dependency>
  </dependencies>
</project>
eyalbe4 commented 9 years ago

@zaiddag, see my comment for this issue. I think both issues talk about the same thing.

skavinvarnan commented 8 years ago

@zaiddag have you found a solution for this?

reaperdtme commented 8 years ago

@skavinvarnan deleted the package entirely, after some time, it'll start working again. Not sure why or how "some time", but it doesn't work right away. >.<

skavinvarnan commented 8 years ago

@zaiddag i finally found the problem. you project name (library name) and the artifactId should be same. But this was my case.

LeebeeDev commented 8 years ago

@skavinvarnan thank you, you made my day

Batzee commented 8 years ago

@skavinvarnan your trick worked :D

eyalbe4 commented 8 years ago

According to the feedback in https://github.com/bintray/gradle-bintray-plugin/issues/81 release 1.6 resolves this issue. Please let us know what you think.

adil-hussain-84 commented 8 years ago

Nope. I still get this issue in release 1.6.

chRyNaN commented 8 years ago

To build upon @skavinvarnan answer, make sure that your module name is also in sync with the artifact and libraryName fields.

adil-hussain-84 commented 8 years ago

@chRyNaN: I got it working in the end. I have a project that consists of a single module (an Android library). In the build.gradle file of the Android module I found I had to specify the group and version doubly as follows to not get the 400 exception:

plugins {
    id 'com.jfrog.bintray' version '1.6'
}

apply plugin: 'maven-publish'
apply plugin: 'com.android.library'

group = "${myGroupName}"
version = "${myVersionName}"

publishing {
    publications {
        MySDK(MavenPublication) {
            groupId "${myGroupName}"
            version "${myVersionName}"
        }
    }
}
eyalbe4 commented 8 years ago

Thanks for sharing this @adil-hussain-84 ! Will you be able to contribute an Android Gradle project example that uses the Bintray Plugin? Thsi could help others in troubleshooting such issues. We can place the example here.

adil-hussain-84 commented 8 years ago

@eyalbe4 Sure. Good idea. I'll put together a small standalone example that demonstrates using the maven-publish plugin together with the com.jfrog.bintray plugin when I get a moment. In the meanwhile, anyone who stumbles across this thread can refer to the build.gradle and Android/build.gradle files in the following repository which publishes an Android library to Bintray:

https://bitbucket.org/adilson05uk/quran-sdk/src

KadamMangesh commented 8 years ago

@adil-hussain-84 - does your library also sync with maven central ?

adil-hussain-84 commented 8 years ago

@MangeshKadam The Bintray publication of the library is linked to jcenter. The linking is done via the Bintray web interface.

easternHong commented 7 years ago

my case ,l forget this line:

group = publishedGroupId

stanmots commented 7 years ago

Solution given by @skavinvarnan still works (I spent a couple of hours trying to figure out what was causing this error)

ramiloif commented 7 years ago

@skavinvarnan May God bless you

braj24 commented 7 years ago

bintrayRepo = 'Your Repo name"' bintrayName = 'Package name' publishedGroupId = 'YOUR GROUP ID' libraryName = 'testlibrary' artifact = 'testlibrary' libraryname and artifact must be same. and also it should match with your library name which was given at the time of creation of Module.

rafaelje commented 7 years ago

This solution work for me, upgrade from 1.4 to 1.6:

rickenwang commented 6 years ago

@rafaelje that's a perfect answer.

hanggrian commented 6 years ago

I'm having the same issue with 1.7.2, but upgrading to 1.8.1 fixes the problem.

debuglevel commented 6 years ago

@hendraanggrian Thank you. For me, it worked with version 1.7 some weeks ago, but stopped recently. Updating to version 1.8 solved the problem.

jplaisted commented 4 years ago

Sorry for the 2+ year bump, but I'm having this issue on the latest version (1.8.5). It looks to me like this could be because I have non-top level modules. e.g. my project may look like

api/
    build.gradle
impl/
    ebean/
        build.gradle
    neo4j/
        build.gradle
build.gradle

Here api is a top level module and ebean and neo4j aren't (they are in the impl directory). If I try to use this plugin with this project structure the gradle task will fail stating that the ebean and neo4j projects had a 400 uploading the pom file, as described in the OP.

Since the top level modules (I have more than one) don't report this error, I assume this is an issue with non top level modules.


EDIT

FWIW I made this task for debugging

task dbg() {
  doFirst {
    println 'project name: ' + project.name
    configurations.archives.allArtifacts.each {
      println 'artifact: ' + it.name + ': ' + it.file.name
    }
  }
}

And here's some example output

> Task :dao-impl:ebean-dao:dbg
project name: ebean-dao
artifact: ebean-dao: ebean-dao-0.0.0.jar
artifact: ebean-dao: ebean-dao-0.0.0-sources.jar
artifact: ebean-dao: ebean-dao-0.0.0-javadoc.jar

So the gradle project name "lines up" with the jar name...


Edit 2:

Nope, moved them out, same error. Not sure why, it's only on those modules. The POM looks right and everything.

  <groupId>com.linkedin.datahub-gma</groupId>
  <artifactId>ebean-dao</artifactId>
  <version>0.0.0</version>

The only difference between this an another "working" pom file is the artifact ID and dependency list, both of which make sense.

Execution failed for task ':ebean-dao:bintrayUpload'.
> Could not upload to 'https://api.bintray.com/content/linkedin/maven/datahub-gma/0.0.0/com/linkedin/datahub-gma/ebean-dao/0.0.0/ebean-dao-0.0.0.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/linkedin/datahub-gma/ebean-dao/0.0.0/ebean-dao-0.0.0.pom']
jplaisted commented 4 years ago

Seems to be something else unrelated to gradle since the POM fails to upload via the UI as well. I'll see if I can reach out to jfrog support.

daniel-schel commented 4 years ago

I had the same issue with maven, perhaps it helps you. The solution was to set the version tag explicitly at the maven modules I want to upload.

jplaisted commented 4 years ago

To update my issue, seems unrelated entirely. I don't know why, but I can only reproduce this when trying to publish version 0.0.0. Bumping up to any other version works fine.

Not an issue with the plugin, but the server. If this is intentional then at the very least the error message is very unclear.