Skip to content

Instantly share code, notes, and snippets.

@darylteo
Last active December 28, 2015 13:49
Show Gist options
  • Select an option

  • Save darylteo/7510475 to your computer and use it in GitHub Desktop.

Select an option

Save darylteo/7510475 to your computer and use it in GitHub Desktop.
Sonatype Configuration for Gradle
apply plugin: 'maven'
apply plugin: 'signing'
project.afterEvaluate {
def release = !project.version.endsWith('-SNAPSHOT')
def sonatypeUsername = project.hasProperty('sonatypeUsername') ? project.sonatypeUsername : '';
def sonatypePassword = project.hasProperty('sonatypePassword') ? project.sonatypePassword: '';
configurations {
archives
}
task sourcesJar(type:Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
task javadocJar(type:Jar) {
from javadoc
classifier = 'javadoc'
}
artifacts {
archives sourcesJar
archives javadocJar
}
signing {
required { release && gradle.taskGraph.hasTask('uploadArchives') }
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
def url = !release ? 'https://oss.sonatype.org/content/repositories/snapshots/' : 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
repository(url: url) {
authentication(userName: sonatypeUsername, password : sonatypePassword)
}
beforeDeployment { dep ->
signing.signPom(dep)
}
uniqueVersion = false
configuration = configurations.archives
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment