Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 74 lines (61 sloc) 1.771 kb
abf18a1 @tomhermann Added maven deloyment script which pushes to a maven repo given the corr...
authored
1 apply plugin: 'signing'
2
3 signing {
4 sign configurations.archives
5 }
6
7 uploadArchives {
8 repositories {
9 mavenDeployer {
10 pom.project {
11 name "${rootProject.name}"
12 packaging 'jar'
13 description "${projectDescription}"
14 url "${projectUrl}"
15
16 scm {
17 url "${projectScm}"
18 connection "${projectScm}"
19 developerConnection "${projectScm}"
20 }
21
22 licenses {
23 license {
24 name 'The Apache Software License, Version 2.0'
25 url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
26 distribution 'repo'
27 }
28 }
29
30 developers {
31 developer {
32 id 'tomhermann'
33 name 'Tom Hermann'
34 }
35 }
36 }
37
38 //mess with the generated pom to set the 'packaging' tag
39 pom.withXml { XmlProvider xmlProvider ->
40 def xml = xmlProvider.asString()
41 def pomXml = new XmlParser().parse(new ByteArrayInputStream(xml.toString().bytes))
42
43 pomXml.version[0] + { packaging('jar') }
44
45 def newXml = new StringWriter()
46 def printer = new XmlNodePrinter(new PrintWriter(newXml))
47 printer.preserveWhitespace = true
48 printer.print(pomXml)
49 xml.setLength(0)
50 xml.append(newXml.toString())
51 }
52 }
53 }
54 }
55
56 def hasDeploymentCredentials = hasProperty('sonatypeUsername') && hasProperty('sonatypePassword')
57
58 if(hasDeploymentCredentials) {
59 uploadArchives {
60 repositories {
61 mavenDeployer {
62 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
63
64 repository(url: projectMavenRepo) {
65 authentication(userName: sonatypeUsername, password: sonatypePassword)
66 }
67 }
68 }
69 }
70 }
71
72 uploadArchives.enabled = hasDeploymentCredentials
73
74 println 'uploadArchives is ' + (hasDeploymentCredentials ? 'enabled' : 'disabled')
Something went wrong with that request. Please try again.