forked from spockframework/spock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
publishMaven.gradle
92 lines (79 loc) · 2.17 KB
/
publishMaven.gradle
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
apply plugin: "maven"
def basePom = {
project {
name project.displayName
description project.description
url "http://spockframework.org"
licenses {
license {
name "The Apache Software License, Version 2.0"
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
distribution "repo"
}
}
scm {
connection "scm:git:git://github.com/spockframework/spock.git"
developerConnection "scm:git:ssh://git@github.com/spockframework/spock.git"
url "http://github.spockframework.org/spock"
}
developers {
developer {
id "pniederw"
name "Peter Niederwieser"
email "peter@pniederw.com"
}
developer {
id "ldaley"
name "Luke Daley"
email "ld@ldaley.com"
}
}
}
}
def deployers = []
project.afterEvaluate {
configure(deployers) {
pom basePom
}
}
install {
deployers << repositories.mavenInstaller
}
uploadArchives {
deployers << repositories.mavenDeployer {
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: "pniederw", password: System.getenv("SONATYPE_OSS_PASSWORD"))
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: "pniederw", password: System.getenv("SONATYPE_OSS_PASSWORD"))
}
}
}
def poms = deployers*.pom
def optionalDeps = []
def providedDeps = []
def internalDeps = []
ext {
modifyPom = { Closure modification ->
poms.each {
it.whenConfigured(modification)
}
}
optional = { optionalDeps << it; it }
provided = { providedDeps << it; it }
internal = { internalDeps << it; it }
}
modifyPom { pom ->
optionalDeps.each { dep ->
pom.dependencies.find { it.artifactId == dep.name }.optional = true
}
providedDeps.each { dep ->
pom.dependencies.find { it.artifactId == dep.name }.scope = "provided"
}
internalDeps.each { dep ->
pom.dependencies.removeAll { it.artifactId == dep.name }
}
// no need to publish test dependencies
pom.dependencies.removeAll { it.scope == "test" }
}
deployers*.beforeDeployment { signing.signPom(it) }