-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaven-deployer.gradle
More file actions
74 lines (61 loc) · 1.73 KB
/
maven-deployer.gradle
File metadata and controls
74 lines (61 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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')