@@ -8,18 +8,99 @@ 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+ }
59+ }
60+
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+ }
69+ }
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+ }
2086}
2187
22- task clean (type : Exec ) {
23- commandLine " ./clean.sh"
24- environment " PROJECT_VERSION" , version
88+ def isSnapshot = version. endsWith(" -SNAPSHOT" )
89+
90+ if (isSnapshot) {
91+ println " Building a -SNAPSHOT version (Github release and Maven Central tasks are skipped)"
92+ tasks. named(" githubRelease" ) {
93+ // snapshot versions do not produce changelog / Github releases
94+ enabled = false
95+ }
96+ tasks. named(" closeAndReleaseStagingRepository" ) {
97+ // snapshot binaries are available in Sonatype without the need to close the staging repo
98+ enabled = false
99+ }
25100}
101+
102+ task writeActualVersion {
103+ doLast {
104+ file(" version.actual" ) << " $version "
105+ }
106+ }
0 commit comments