Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
74 lines (61 sloc) 1.73 KB
apply plugin: 'signing'
signing {
sign configurations.archives
}
uploadArchives {
repositories {
mavenDeployer {
pom.project {
name "${rootProject.name}"
packaging 'jar'
description "${projectDescription}"
url "${projectUrl}"
scm {
url "${projectScm}"
connection "${projectScm}"
developerConnection "${projectScm}"
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'tomhermann'
name 'Tom Hermann'
}
}
}
//mess with the generated pom to set the 'packaging' tag
pom.withXml { XmlProvider xmlProvider ->
def xml = xmlProvider.asString()
def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes))
pomXml.version[0] + { packaging('jar') }
def newXml = new StringWriter()
def printer = new XmlNodePrinter(new PrintWriter(newXml))
printer.preserveWhitespace = true
printer.print(pomXml)
xml.setLength(0)
xml.append(newXml.toString())
}
}
}
}
def hasDeploymentCredentials = hasProperty('sonatypeUsername') && hasProperty('sonatypePassword')
if(hasDeploymentCredentials) {
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
repository(url: projectMavenRepo) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
}
}
}
}
uploadArchives.enabled = hasDeploymentCredentials
println 'uploadArchives is ' + (hasDeploymentCredentials ? 'enabled' : 'disabled')
Jump to Line
Something went wrong with that request. Please try again.