0

I am trying to deploy my artefacts to Bintray with the official Gradle plugin. Contrary to my expectations, the plugin does not use the version which is set in the build.gradle, but autogenerates a random version string like this:

myproject-build_ewroptgflyd6opkee3goj0l63$_run_closure10$_closure30@3afaa4d9.jar
myproject-build_ewroptgflyd6opkee3goj0l63$_run_closure10$_closure30@3afaa4d9-javadoc.jar
myproject-build_ewroptgflyd6opkee3goj0l63$_run_closure10$_closure30@3afaa4d9-sources.jar

My build.gradle looks like this. I compared my configuration with several configurations online, but did not find any discrepancies.

plugins {
    id "com.jfrog.bintray" version "1.8.0"
}

group = 'com.test'
version = '0.1'

allprojects {
    apply plugin: 'java'
    apply plugin: 'maven-publish'

    repositories {
        jcenter()
        mavenCentral()
    }

    sourceCompatibility = 1.9
    targetCompatibility = 1.9
}

/****************************************
 * Single library "fat-jar" containing all sub projects and 3rd party dependencies
 ****************************************/
configurations {
    childJars
}

dependencies {
    subprojects.each {
        childJars project(it.path)
    }
}

jar {
    dependsOn configurations.childJars
    exclude('**/logback.xml')
    from { configurations.childJars.collect { zipTree(it) } }
}

task sourcesJar(type: Jar, dependsOn: classes) {
    classifier = 'sources'
    from sourceSets.main.allSource
}

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

artifacts {
    archives sourcesJar
    archives javadocJar
}

/****************************************
 * Bintray deployment (needed for Maven Central)
 ****************************************/
bintray {
    user = System.getenv('BINTRAY_USER') // bintray username (not organisation)
    key = System.getenv('BINTRAY_KEY')   // api-key
    override = true

    publications = ['MavenCustom']
    pkg {
        repo = 'my-repository'
        name = 'my-package'
        userOrg = 'my-organisation'
        licenses = ['AGPL-V3']
        websiteUrl = 'https://github.com/myproject'
        issueTrackerUrl = 'https://github.com/myproject/issues'
        vcsUrl = 'https://github.com/myproject.git'
    }
    version {
        name = project.version
        released = new Date()
    }
}

// Create the pom configuration:
def pomConfig = {
    licenses {
        license {
            name 'GNU AFFERO GENERAL PUBLIC LICENSE, Version 3.0'
            url 'https://www.gnu.org/licenses/agpl.txt'
            distribution 'repo'
        }
    }
    developers {
        developer {
            id 'developer-id'
            name 'developer-name'
            email 'developer@me'
        }
    }

    scm {
        url 'https://github.com/myproject'
        connection 'https://git@github.com/myproject.git'
        developerConnection 'scm:git:https://github.com/myproject.git'
    }
}

publishing {
    publications {
        MavenCustom(MavenPublication) {
            from components.java
            artifact sourcesJar {
                classifier "sources"
            }
            artifact javadocJar {
                classifier "javadoc"
            }
            groupId project.group
            artifactId project.name
            version project.version
            pom.withXml {
                def root = asNode()
                root.appendNode('description', 'descr')
                root.appendNode('name', 'Project Name')
                root.appendNode('url', 'https://github.com/myproject')
                root.children().last() + pomConfig
            }
        }
    }
}

model {
    tasks.generatePomFileForMavenCustomPublication {
        destination = file("$buildDir/libs/pom.xml")
    }
}
  • Actually I can force that the generated artefacts use the given version, if I apply "baseName project.name" and "version project.version" to the jar, sourcesJar, and javaDocJar. However the bintrayUpload task of the Gradle Plugin still uses the cryptic autogenerated version. –  May 22 '18 at 07:35
  • It appears that if I just leave the "mandatory" version section away (from the bintray closure), everything works as expected.. –  May 22 '18 at 08:53
  • I run into a similar situation, in the end I took the novoda plugin for publishing my artifacts – rekire Feb 28 '19 at 20:34

0 Answers0