-
Notifications
You must be signed in to change notification settings - Fork 60
/
build.gradle
121 lines (104 loc) · 4.11 KB
/
build.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
buildscript {
repositories {
mavenLocal()
maven { url "https://plugins.gradle.org/m2/" }
}
dependencies {
//Using buildscript.classpath so that we can resolve plugins from maven local, during local testing
classpath "org.shipkit:shipkit-auto-version:1.+"
classpath "org.shipkit:shipkit-changelog:1.+"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}
group = 'org.mockito'
apply from: "gradle/shipkit.gradle"
apply plugin: "maven-publish"
def pubNames = []
publishing {
publications {
int i = 1
[
"mockito-scala_2.11", "mockito-scala_2.12", "mockito-scala_2.13",
"mockito-scala-cats_2.11", "mockito-scala-cats_2.12", "mockito-scala-cats_2.13",
"mockito-scala-scalatest_2.11", "mockito-scala-scalatest_2.12", "mockito-scala-scalatest_2.13",
"mockito-scala-scalaz_2.11", "mockito-scala-scalaz_2.12", "mockito-scala-scalaz_2.13",
"mockito-scala-specs2_2.11", "mockito-scala-specs2_2.12", "mockito-scala-specs2_2.13",
].each {pub ->
String pubName = "publication${i++}"
pubNames << pubName
"$pubName"(MavenPublication) {
groupId = 'org.mockito'
artifactId = pub
def jarFile = file("target/dist/org/mockito/${pub}/${version}/${pub}-${version}.jar")
artifact jarFile
def srcFile = file("target/dist/org/mockito/${pub}/${version}/${pub}-${version}-sources.jar")
artifact source: srcFile, classifier: "sources"
def jFile = file("target/dist/org/mockito/${pub}/${version}/${pub}-${version}-javadoc.jar")
artifact source: jFile, classifier: "javadoc"
pom {
withXml {
def xml = asString()
xml.setLength(0)
def pomFile = file("target/dist/org/mockito/${pub}/${version}/${pub}-${version}.pom")
assert pomFile.file
xml.append(pomFile.text)
}
}
}
}
}
}
apply plugin: 'signing' //https://docs.gradle.org/current/userguide/signing_plugin.html
signing {
if (System.getenv("PGP_KEY")) {
useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD"))
pubNames.each {
sign publishing.publications."$it"
}
}
}
apply plugin: "io.github.gradle-nexus.publish-plugin"
nexusPublishing {
repositories {
if (System.getenv("NEXUS_TOKEN_PWD")) {
sonatype {
// Publishing to: https://s01.oss.sonatype.org (faster instance)
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
username = System.getenv("NEXUS_TOKEN_USER")
password = System.getenv("NEXUS_TOKEN_PWD")
}
}
}
}
task writeActualVersion {
doLast {
file("version.actual") << "$version"
}
}
def isSnapshot = version.endsWith("-SNAPSHOT")
if (isSnapshot) {
println "Building a -SNAPSHOT version (GitHub release and Maven Central tasks are skipped)"
tasks.named("githubRelease") {
//snapshot versions do not produce changelog / GitHub releases
enabled = false
}
tasks.named("closeAndReleaseStagingRepository") {
//snapshot binaries are available in Sonatype without the need to close the staging repo
enabled = false
}
}
tasks.register("releaseSummary") {
doLast {
if (isSnapshot) {
println "RELEASE SUMMARY\n" +
" SNAPSHOTS released to: https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/\n" +
" Release to Maven Central: SKIPPED FOR SNAPSHOTS\n" +
" GitHub releases: SKIPPED FOR SNAPSHOTS"
} else {
println "RELEASE SUMMARY\n" +
" Release to Maven Central (available after delay): https://repo1.maven.org/maven2/org/mockito/\n" +
" GitHub releases: https://github.com/mockito/mockito-scala/releases"
}
}
}