forked from gradle-nexus/publish-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
276 lines (255 loc) · 8.65 KB
/
build.gradle.kts
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation
import org.gradle.initialization.IGradlePropertiesLoader.ENV_PROJECT_PROPERTIES_PREFIX
import org.gradle.initialization.IGradlePropertiesLoader.SYSTEM_PROJECT_PROPERTIES_PREFIX
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`kotlin-dsl`
`maven-publish`
id("com.gradle.plugin-publish") version "0.15.0"
id("com.diffplug.spotless") version "5.12.5"
id("com.github.johnrengelman.shadow") version "6.1.0"
id("org.jetbrains.gradle.plugin.idea-ext")
id("com.github.ben-manes.versions") version "0.39.0"
id("org.jetbrains.dokka") version "1.4.32"
id("org.ajoberstar.stutter") version "0.6.0"
}
group = "io.github.gradle-nexus"
version = "1.1.1-SNAPSHOT"
val readableName = "Nexus Publish Plugin"
description = "Gradle Plugin for publishing to Nexus that automates creating, closing, and releasing staging repositories"
val repoUrl = "https://github.com/gradle-nexus/publish-plugin"
pluginBundle {
description = project.description
website = repoUrl
vcsUrl = repoUrl
tags = listOf("publishing", "maven", "nexus")
}
gradlePlugin {
plugins {
create("nexusPublish") {
id = "io.github.gradle-nexus.publish-plugin"
displayName = readableName
implementationClass = "io.github.gradlenexus.publishplugin.NexusPublishPlugin"
}
}
}
repositories {
mavenCentral()
}
val licenseHeaderFile = file("gradle/license-header.txt")
spotless {
kotlin {
targetExclude("**/*.gradle.kts")
//"import-ordering" required here as it started to fail after spotless plugin upgrade to 0.35.0 - resolve in separate PR
ktlint().userData(mapOf("disabled_rules" to "comment-spacing,import-ordering"))
licenseHeaderFile(licenseHeaderFile)
}
}
idea {
project {
settings {
copyright {
useDefault = "Apache-2.0"
profiles {
create("Apache-2.0") {
notice = readCopyrightHeader(licenseHeaderFile)
keyword = "Copyright"
}
}
}
}
}
}
val shadowed by configurations.creating
configurations {
compileOnly {
extendsFrom(shadowed)
}
testImplementation {
extendsFrom(shadowed)
exclude(group = "junit", module = "junit")
}
}
dependencies {
shadowed("com.squareup.retrofit2:retrofit:2.9.0")
shadowed("com.squareup.retrofit2:converter-gson:2.9.0")
shadowed("net.jodah:failsafe:2.4.0")
testImplementation("org.junit.jupiter:junit-jupiter:5.7.2")
testImplementation("com.github.tomakehurst:wiremock:2.27.2")
testImplementation("ru.lanwen.wiremock:wiremock-junit5:1.3.1")
testImplementation("org.assertj:assertj-core:3.19.0")
testImplementation("org.mockito:mockito-junit-jupiter:3.11.0")
testImplementation("com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0")
}
java {
withJavadocJar()
withSourcesJar()
}
stutter {
isSparse = (findProperty("stutter.sparce")?.toString()?.toBoolean()) ?: true
java(8) {
compatibleRange("5.0")
}
java(11) {
compatibleRange("5.0")
}
java(15) {
compatibleRange("6.6")
}
}
val e2eTest by sourceSets.creating { //separate infrastructure as compatTest is called multiple times with different Java versions
compileClasspath += sourceSets["compatTest"].output
compileClasspath += sourceSets["main"].output
runtimeClasspath += sourceSets["compatTest"].output
runtimeClasspath += sourceSets["main"].output
}
configurations {
compatTestCompileClasspath {
extendsFrom(testCompileClasspath.get())
}
compatTestRuntimeClasspath {
extendsFrom(testRuntimeClasspath.get())
}
configurations.named(e2eTest.implementationConfigurationName) {
extendsFrom(compatTestCompileClasspath.get())
}
configurations.named(e2eTest.runtimeOnlyConfigurationName) {
extendsFrom(compatTestRuntimeClasspath.get())
}
}
sourceSets {
compatTest {
compileClasspath += sourceSets["test"].output
compileClasspath += sourceSets["main"].output
runtimeClasspath += sourceSets["test"].output
runtimeClasspath += sourceSets["main"].output
}
}
kotlinDslPluginOptions {
experimentalWarning.set(false)
}
tasks {
withType<KotlinCompile>().configureEach {
kotlinOptions.jvmTarget = "1.8"
}
val relocateShadowJar by registering(ConfigureShadowRelocation::class) {
target = shadowJar.get()
prefix = "io.github.gradlenexus.publishplugin.shadow"
}
shadowJar {
dependsOn(relocateShadowJar)
configurations = listOf(shadowed)
exclude("META-INF/maven/**", "META-INF/proguard/**", "META-INF/*.kotlin_module")
manifest {
attributes["Implementation-Version"] = project.version
}
archiveClassifier.set("")
}
jar {
enabled = false
dependsOn(shadowJar)
}
pluginUnderTestMetadata {
pluginClasspath.from.clear()
pluginClasspath.from(shadowJar)
}
register<Test>("e2eTest") {
description = "Run E2E tests."
group = "Verification"
testClassesDirs = e2eTest.output.classesDirs
classpath = e2eTest.runtimeClasspath
//pass E2E releasing properties to tests. Prefer environment variables which are not displayed with --info
// (unless non CI friendly properties with "." are used)
listOf("sonatypeUsername", "sonatypePassword", "signingKey", "signingPassword", "signing.gnupg.homeDir", "signing.gnupg.keyName", "signing.gnupg.passphrase").forEach {
val e2eName = "${it}E2E"
val e2eEnvName = "${ENV_PROJECT_PROPERTIES_PREFIX}${e2eName}"
//properties defined using ORG_GRADLE_PROJECT_ are accessible in child process anyway
if (project.hasProperty(e2eName) && System.getenv(e2eEnvName) == null) {
if (e2eName.contains(".")) {
systemProperties.put("${SYSTEM_PROJECT_PROPERTIES_PREFIX}${e2eName}", project.property(e2eName))
} else {
environment("$ENV_PROJECT_PROPERTIES_PREFIX${e2eName}", project.property(e2eName)!!)
}
}
}
if (project.findProperty("e2eVerboseOutput") != null && project.findProperty("e2eVerboseOutput") != "false") {
testLogging {
showStandardStreams = true
}
}
}
withType<Test>().configureEach {
dependsOn(shadowJar)
useJUnitPlatform()
maxParallelForks = 8
}
withType<Test>().matching { it.name.startsWith("compatTest") }.configureEach {
systemProperty("plugin.version", project.version)
}
dokkaJavadoc {
outputDirectory.set(file("$buildDir/javadoc"))
dokkaSourceSets.configureEach {
reportUndocumented.set(false)
jdkVersion.set(8)
perPackageOption {
matchingRegex.set(".*\\.internal($|\\.).*")
suppress.set(true)
}
}
}
javadoc {
enabled = false
}
named<Jar>("javadocJar").configure {
from(dokkaJavadoc)
}
}
configurations {
configureEach {
outgoing {
val removed = artifacts.removeIf { it.classifier.isNullOrEmpty() }
if (removed) {
artifact(tasks.shadowJar) {
classifier = ""
}
}
}
}
// used by plugin-publish plugin
archives {
outgoing {
artifact(tasks.named("sourcesJar"))
artifact(tasks.named("javadocJar"))
}
}
}
publishing {
publications {
afterEvaluate {
named<MavenPublication>("pluginMaven") {
pom {
name.set(readableName)
description.set(project.description)
inceptionYear.set("2020")
url.set(repoUrl)
developers {
developer {
name.set("Marc Philipp")
id.set("marcphilipp")
}
developer {
name.set("Marcin Zajączkowski")
id.set("szpak")
}
}
licenses {
license {
name.set("Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
}
}
}
}
}