Skip to content

Instantly share code, notes, and snippets.

@int128
Last active August 17, 2017 07:55
Show Gist options
  • Save int128/bc58cb72fe6d8feabfb3 to your computer and use it in GitHub Desktop.
Save int128/bc58cb72fe6d8feabfb3 to your computer and use it in GitHub Desktop.
Publish the artifact to Bintray and Maven Central

Publish to Bintray and Maven Central

Add your Bintray user and key to ~/.gradle/gradle.properties as follows.

bintrayUser=example
bintrayKey=secret

Run the task.

./gradlew uploadBintray
plugins {
id 'groovy'
id 'maven-publish'
id 'com.jfrog.bintray' version '0.6'
}
task javadocJar(type: Jar, dependsOn: groovydoc) {
from "${buildDir}/docs/groovydoc"
classifier = 'javadoc'
}
task sourcesJar(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
publishing {
publications {
maven(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar
pom.withXml {
asNode().children().last() + {
resolveStrategy = DELEGATE_FIRST
name project.name
description project.description
url project.property('pom.url')
scm {
url project.property('pom.scm.url')
connection project.property('pom.scm.connection')
}
licenses {
license {
name project.property('pom.license.name')
url project.property('pom.license.url')
distribution 'repo'
}
}
developers {
developer {
id project.property('pom.developer.id')
name project.property('pom.developer.name')
}
}
}
}
}
}
}
bintray {
user = project.properties.bintrayUser
key = project.properties.bintrayKey
publications = ['maven']
pkg {
repo = 'maven'
name = project.name
}
}
tasks.bintrayUpload.doFirst {
assert !project.version.contains('SNAPSHOT')
}
pom.url=https://github.com/example
[email protected]:example
pom.scm.connection=scm:git:[email protected]:example
pom.license.name=The Apache Software License, Version 2.0
pom.license.url=http://www.apache.org/licenses/LICENSE-2.0.txt
pom.developer.id=example
pom.developer.name=example
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment