8000 Introduce release convention plugin for Shipkit integration (#3533) · mockito/mockito@2c184c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2c184c9

Browse files
authored
Introduce release convention plugin for Shipkit integration (#3533)
1 parent 68c4285 commit 2c184c9

File tree

5 files changed

+83
-71
lines changed

5 files changed

+83
-71
lines changed

build.gradle.kts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,17 @@ buildscript {
66
}
77

88
dependencies {
9-
classpath("io.github.gradle-nexus:publish-plugin:2.0.0-rc-1")
10-
classpath("org.shipkit:shipkit-changelog:2.0.1")
11-
classpath("org.shipkit:shipkit-auto-version:2.1.0")
12-
139
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.24")
1410
}
1511
}
1612

1713
plugins {
1814
id("eclipse")
1915
id("com.github.ben-manes.versions") version "0.51.0"
16+
id("mockito.root.releasing-conventions")
2017

2118
// Top-level android plugin declaration required for :mockito-integration-tests:android-tests to work
2219
alias(libs.plugins.android.application) apply false
2320
}
2421

25-
apply {
26-
from(rootProject.file("gradle/shipkit.gradle"))
27-
}
2822

buildSrc/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ dependencies {
1212
implementation(libs.gradleplugin.spotless.googleJavaFormat)
1313
implementation(libs.gradleplugin.license)
1414

15+
implementation(libs.gradleplugin.nexusPublish)
16+
implementation(libs.gradleplugin.shipkit.changelog)
17+
implementation(libs.gradleplugin.shipkit.autoVersion)
18+
1519
// https://github.com/gradle/gradle/issues/15383
1620
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
1721
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
plugins {
2+
id("org.shipkit.shipkit-auto-version")
3+
id("org.shipkit.shipkit-changelog")
4+
id("org.shipkit.shipkit-github-release")
5+
6+
id("io.github.gradle-nexus.publish-plugin")
7+
}
8+
9+
val isSnapshot = version.toString().endsWith("SNAPSHOT")
10+
val githubTokenProvider = providers.environmentVariable("GITHUB_TOKEN")
11+
val githubShaProvider = providers.environmentVariable("GITHUB_SHA")
12+
val mockitoRepository = "mockito/mockito"
13+
14+
tasks {
15+
generateChangelog {
16+
githubToken = githubTokenProvider.get()
17+
previousRevision = project.ext["shipkit-auto-version.previous-tag"].toString()
18+
repository = mockitoRepository
19+
}
20+
21+
githubRelease {
22+
enabled = !isSnapshot
23+
dependsOn(generateChangelog)
24+
githubToken = githubTokenProvider.get()
25+
newTagRevision = githubShaProvider.get()
26+
repository = mockitoRepository
27+
changelog = generateChangelog.get().outputFile
28+
}
29+
30+
closeAndReleaseStagingRepositories {
31+
enabled = !isSnapshot
32+
}
33+
34+
val releaseSummary by registering {
35+
doLast {
36+
if (isSnapshot) {
37+
logger.lifecycle(
38+
"""
39+
RELEASE SUMMARY
40+
SNAPSHOTS released to: https://s01.oss.sonatype.org/content/repositories/snapshots/org/mockito/mockito-core
41+
Release to Maven Central: SKIPPED FOR SNAPSHOTS
42+
Github releases: SKIPPED FOR SNAPSHOTS
43+
""".trimIndent()
44+
)
45+
} else {
46+
logger.lifecycle(
47+
"""
48+
RELEASE SUMMARY
49+
Release to Maven Central (available in few hours): https://repo1.maven.org/maven2/org/mockito/mockito-core/
50+
Github releases: https://github.com/mockito/mockito/releases
51+
""".trimIndent()
52+
)
53+
}
54+
}
55+
}
56+
}
57+
58+
nexusPublishing {
59+
packageGroup = "org.mockito"
60+
repositoryDescription = provider { "Mockito ${project.version}" }
61+
62+
repositories {
63+
if (!providers.environmentVariable("NEXUS_TOKEN_PWD").orNull.isNullOrBlank()) {
64+
sonatype {
65+
// Publishing to: https://s01.oss.sonatype.org (faster instance)
66+
nexusUrl = uri("https://s01.oss.sonatype.org/service/local/")
67+
snapshotRepositoryUrl = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
68+
69+
username = providers.environmentVariable("NEXUS_TOKEN_USER")
70+
password = providers.environmentVariable("NEXUS_TOKEN_PWD")
71+
}
72+
}
73+
}
74+
}
75+

gradle/libs.versions.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ gradleplugin-errorprone = { module = "net.ltgt.gradle:gradle-errorprone-plugin",
4848
gradleplugin-spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version.ref = "gradleplugin-spotless" }
4949
gradleplugin-spotless-googleJavaFormat = { module = "com.google.googlejavaformat:google-java-format", version = "1.25.2" }
5050
gradleplugin-license = { module = "com.github.hierynomus.license:com.github.hierynomus.license.gradle.plugin", version = "0.16.1" }
51+
gradleplugin-nexusPublish = { module = "io.github.gradle-nexus:publish-plugin", version = "2.0.0" }
52+
gra 688A dleplugin-shipkit-changelog = { module = "org.shipkit:shipkit-changelog", version = "2.0.1" }
53+
gradleplugin-shipkit-autoVersion = { module = "org.shipkit:shipkit-auto-version", version = "2.1.0" }
5154

5255
# animal sniffer compatibility signatures
5356
animalSniffer-android-apiLevel26 = { module = "net.sf.androidscents.signature:android-api-level-26", version = "8.0.0_r2" }

gradle/shipkit.gradle

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0