@@ -8,18 +8,114 @@ buildscript {
88 // Using buildscript.classpath so that we can resolve plugins from maven local, during local testing
99 classpath " org.shipkit:shipkit-auto-version:1.+"
1010 classpath " org.shipkit:shipkit-changelog:1.+"
11- classpath " com.jfrog.bintray. gradle:gradle-bintray- plugin:1.+ "
11+ classpath " io.github. gradle-nexus:publish- plugin:1.1.0 "
1212 }
1313}
1414
15+ group = ' org.mockito'
16+
1517apply from : " gradle/shipkit.gradle"
1618
17- task build (type : Exec ) {
18- commandLine " ./build.sh"
19- environment " PROJECT_VERSION" , version
19+ apply plugin : " maven-publish"
20+
21+ def pubNames = []
22+ publishing {
23+ publications {
24+ int i = 1
25+ [
26+ " mockito-scala_2.11" , " mockito-scala_2.12" , " mockito-scala_2.13" ,
27+ " mockito-scala-cats_2.11" , " mockito-scala-cats_2.12" , " mockito-scala-cats_2.13" ,
28+ " mockito-scala-scalatest_2.11" , " mockito-scala-scalatest_2.12" , " mockito-scala-scalatest_2.13" ,
29+ " mockito-scala-scalaz_2.11" , " mockito-scala-scalaz_2.12" , " mockito-scala-scalaz_2.13" ,
30+ " mockito-scala-specs2_2.11" , " mockito-scala-specs2_2.12" , " mockito-scala-specs2_2.13" ,
31+ ]. each {pub ->
32+ String pubName = " publication${ i++} "
33+ pubNames << pubName
34+ " $pubName " (MavenPublication ) {
35+ groupId = ' org.mockito'
36+ artifactId = pub
37+
38+ def jarFile = file(" target/dist/org/mockito/${ pub} /${ version} /${ pub} -${ version} .jar" )
39+ artifact jarFile
40+
41+ def srcFile = file(" target/dist/org/mockito/${ pub} /${ version} /${ pub} -${ version} -sources.jar" )
42+ artifact source : srcFile, classifier : " sources"
43+
44+ def jFile = file(" target/dist/org/mockito/${ pub} /${ version} /${ pub} -${ version} -javadoc.jar" )
45+ artifact source : jFile, classifier : " javadoc"
46+
47+ pom {
48+ withXml {
49+ def xml = asString()
50+ xml. setLength(0 )
51+ def pomFile = file(" target/dist/org/mockito/${ pub} /${ version} /${ pub} -${ version} .pom" )
52+ assert pomFile. file
53+ xml. append(pomFile. text)
54+ }
55+ }
56+ }
57+ }
58+ }
2059}
2160
22- task clean (type : Exec ) {
23- commandLine " ./clean.sh"
24- environment " PROJECT_VERSION" , version
61+ apply plugin : ' signing' // https://docs.gradle.org/current/userguide/signing_plugin.html
62+ signing {
63+ if (System . getenv(" PGP_KEY" )) {
64+ useInMemoryPgpKeys(System . getenv(" PGP_KEY" ), System . getenv(" PGP_PWD" ))
65+ pubNames. each {
66+ sign publishing. publications. " $it "
67+ }
68+ }
2569}
70+
71+ apply plugin : " io.github.gradle-nexus.publish-plugin"
72+
73+ nexusPublishing {
74+ repositories {
75+ if (System . getenv(" NEXUS_TOKEN_PWD" )) {
76+ sonatype {
77+ // Publishing to: https://s01.oss.sonatype.org (faster instance)
78+ nexusUrl = uri(" https://s01.oss.sonatype.org/service/local/" )
79+ snapshotRepositoryUrl = uri(" https://s01.oss.sonatype.org/content/repositories/snapshots/" )
80+
81+ username = System . getenv(" NEXUS_TOKEN_USER" )
82+ password = System . getenv(" NEXUS_TOKEN_PWD" )
83+ }
84+ }
85+ }
86+ }
87+
88+ task writeActualVersion {
89+ doLast {
90+ file(" version.actual" ) << " $version "
91+ }
92+ }
93+
94+ def isSnapshot = version. endsWith(" -SNAPSHOT" )
95+
96+ if (isSnapshot) {
97+ println " Building a -SNAPSHOT version (Github release and Maven Central tasks are skipped)"
98+ tasks. named(" githubRelease" ) {
99+ // snapshot versions do not produce changelog / Github releases
100+ enabled = false
101+ }
102+ tasks. named(" closeAndReleaseStagingRepository" ) {
103+ // snapshot binaries are available in Sonatype without the need to close the staging repo
104+ enabled = false
105+ }
106+ }
107+
108+ tasks. register(" releaseSummary" ) {
109+ doLast {
110+ if (isSnapshot) {
111+ println " RELEASE SUMMARY\n " +
112+ " SNAPSHOTS released to: https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/kotlin/mockito-kotlin\n " +
113+ " Release to Maven Central: SKIPPED FOR SNAPSHOTS\n " +
114+ " Github releases: SKIPPED FOR SNAPSHOTS"
115+ } else {
116+ println " RELEASE SUMMARY\n " +
117+ " Release to Maven Central (available after delay): https://repo1.maven.org/maven2/org/mockito/kotlin/mockito-kotlin/\n " +
118+ " Github releases: https://github.com/mockito/mockito-kotlin/releases"
119+ }
120+ }
121+ }
0 commit comments