Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Publishing artifact from gradle project to bintray (maven repository)

I have configured Gradle to publish project artifact using new Maven Publisher Plugin, unfortunately this plugin has problem with dependency in generated pom.xml - dependencies has scope runtime instead of compile.

My configuration is like this:

apply plugin: 'maven-publish'

publishing {
    publications {
        mavenCustom(MavenPublication) {
            from components.java
        }
    }
    repositories {
        maven {
            url "https://api.bintray.com/maven/codearte/public/fairyland"
            credentials {
                username = bintrayUser
                password = bintrayKey
            }
        }
    }
}

Publishing was simple with one command:

gradle publish

How to achieve this in old (working) way? Is possible to automate project taging when project is released?

like image 706
MariuszS Avatar asked Nov 21 '13 21:11

MariuszS


2 Answers

Ok, I figured it out:

apply plugin: 'maven'

uploadArchives {
    repositories {
        mavenDeployer {
            name = 'Codearte Public Repository'
            repository(id: 'codearte-repository', url: 'https://api.bintray.com/maven/codearte/public/fairyland'){
                authentication(userName: bintrayUser, password: bintrayKey)
        }
    }
}

Uploading with command:

gradle uploadArchives
like image 97
MariuszS Avatar answered Nov 08 '22 12:11

MariuszS


The fact that all POM dependencies have runtime scope is a known limitation of the new, incubating maven-publish plugin. Until this gets fixed, you can either fix it up yourself by using the publication.pom.withXml hook, or fall back to the maven plugin. Both plugins are documented in the Gradle User Guide.

Tagging is an entirely different question. You can either use one of the third-party Gradle SCM plugins or call out to a command line tool (e.g. with an Exec task).

like image 31
Peter Niederwieser Avatar answered Nov 08 '22 12:11

Peter Niederwieser