• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1buildscript {
2    repositories {
3        mavenLocal()        // for local testing
4        maven { url "https://plugins.gradle.org/m2/" }
5    }
6    dependencies {
7        classpath "org.shipkit:shipkit-changelog:1.2.0"
8        classpath "org.shipkit:shipkit-auto-version:1.2.2"
9        classpath "io.github.gradle-nexus:publish-plugin:1.0.0"
10    }
11}
12
13apply plugin: "io.github.gradle-nexus.publish-plugin"
14apply plugin: 'org.shipkit.shipkit-auto-version'
15apply plugin: "org.shipkit.shipkit-changelog"
16apply plugin: "org.shipkit.shipkit-github-release"
17
18allprojects {
19    group = 'org.mockito.kotlin'
20}
21
22tasks.named("generateChangelog") {
23    previousRevision = project.ext.'shipkit-auto-version.previous-version'
24    githubToken = System.getenv("GITHUB_TOKEN")
25    repository = "mockito/mockito-kotlin"
26    releaseTag = project.version
27}
28
29tasks.named("githubRelease") {
30    def genTask = tasks.named("generateChangelog").get()
31    dependsOn genTask
32    repository = genTask.repository
33    changelog = genTask.outputFile
34    githubToken = System.getenv("GITHUB_TOKEN")
35    newTagRevision = System.getenv("GITHUB_SHA")
36    releaseTag = project.version
37    releaseName = project.version
38}
39
40nexusPublishing {
41    repositories {
42        if (System.getenv("NEXUS_TOKEN_PWD")) {
43            sonatype {
44                // Publishing to: https://s01.oss.sonatype.org (faster instance)
45                nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
46                snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
47
48                username = System.getenv("NEXUS_TOKEN_USER")
49                password = System.getenv("NEXUS_TOKEN_PWD")
50            }
51        }
52    }
53}
54
55def isSnapshot = version.endsWith("-SNAPSHOT")
56
57if (isSnapshot) {
58    println "Building a -SNAPSHOT version (Github release and Maven Central tasks are skipped)"
59    tasks.named("githubRelease") {
60        //snapshot versions do not produce changelog / Github releases
61        enabled = false
62    }
63    tasks.named("closeAndReleaseStagingRepository") {
64        //snapshot binaries are available in Sonatype without the need to close the staging repo
65        enabled = false
66    }
67}
68
69tasks.register("releaseSummary") {
70    doLast {
71        if (isSnapshot) {
72            println "RELEASE SUMMARY\n" +
73                    "  SNAPSHOTS released to: https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/kotlin/mockito-kotlin\n" +
74                    "  Release to Maven Central: SKIPPED FOR SNAPSHOTS\n" +
75                    "  Github releases: SKIPPED FOR SNAPSHOTS"
76        } else {
77            println "RELEASE SUMMARY\n" +
78                    "  Release to Maven Central (available after delay): https://repo1.maven.org/maven2/org/mockito/kotlin/mockito-kotlin/\n" +
79                    "  Github releases: https://github.com/mockito/mockito-kotlin/releases"
80        }
81    }
82}
83