bintray / gradle-bintray-plugin

Apache License 2.0
1.28k stars 194 forks source link

bintrayUpload task does not depend on publicXXXPublishToMavenLocal #205

Open hkhc opened 6 years ago

hkhc commented 6 years ago

I have the following snippet in build.gradle. (with gradle-bintray-plugin version 1.8.0)

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

bintray {
    user = System.getenv('BINTRAY_USER')
    key = System.getenv('BINTRAY_KEY')
    publications = ['Bintray']
    override = true
    dryRun = false
    pkg {
        repo = 'maven'
        name = project.findProperty("artifactId")
        desc = 'I am description'
        licenses = ['Apache-2.0']
        websiteUrl = 'https://github.com/....'
        vcsUrl = 'https://github.com/....'
        issueTrackerUrl = 'https://github.com/..../issues'
        githubRepo = '....'
        githubReleaseNotesFile = 'README.md'
        version {
            name = project.findProperty('version')
            desc = 'I am description'
            released  = new Date()
            vcsTag = project.findProperty("version")
        }
    }

}

when I try to run bintrayUpload, the archives is not generated unless I run publishBintrayPublicationToMavenLocal task explicitly.

However, in the source code of BintrayPlugin.groovy, I see it does try to make bintrayUpload task depends on the above publish....PublicationToMavenLocal task. But in reality it is not the case.

It turn out that I added the following to the end of the script to link the two tasks, and it work

afterEvaluate {

    publishing.publications.each {
        if (it instanceof MavenPublication) {
            def publishTask = "publish${it.name[0].toUpperCase()}${it.name.substring(1)}PublicationToMavenLocal"
            project.tasks.findByName("bintrayUpload").dependsOn(publishTask)
        }
    }

}

The problem is that it is a bug or a feature ;-) ?

hkhc commented 6 years ago

I created a PR for that #206

ber4444 commented 6 years ago

Thanks a ton, finally my pom file is published! This PR should definitely go to the next release...

sponiro commented 6 years ago

This is a duplicate of #10