-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle.kts
249 lines (222 loc) · 9.15 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
import com.github.vlsi.gradle.crlf.CrLfSpec
import com.github.vlsi.gradle.crlf.LineEndings
import com.github.vlsi.gradle.dsl.configureEach
import com.github.vlsi.gradle.properties.dsl.props
import com.github.vlsi.gradle.publishing.dsl.simplifyXml
import com.github.vlsi.gradle.publishing.dsl.versionFromResolution
import org.gradle.api.tasks.wrapper.Wrapper.DistributionType
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
`maven-publish`
`kotlin-dsl`
id("com.gradle.plugin-publish") version "0.12.0"
id("com.github.vlsi.crlf") version "1.70"
id("com.github.vlsi.gradle-extensions") version "1.70"
id("com.github.vlsi.stage-vote-release") version "1.70"
}
repositories {
jcenter()
}
val String.v: String get() = rootProject.extra["$this.version"] as String
val buildVersion = "current".v + releaseParams.snapshotSuffix
println("Building gradle-multi-cache $buildVersion")
val enableGradleMetadata by props()
val autostyleSelf by props()
val skipAutostyle by props()
val skipJavadoc by props()
releaseParams {
tlp.set("gradle-multi-cache")
organizationName.set("burrunan")
componentName.set("gradle-multi-cache")
prefixForProperties.set("gh")
svnDistEnabled.set(false)
sitePreviewEnabled.set(false)
nexus {
mavenCentral()
// https://github.com/marcphilipp/nexus-publish-plugin/issues/35
packageGroup.set("com.github.burrunan")
}
voteText.set {
"""
${it.componentName} v${it.version}-rc${it.rc} is ready for preview.
Git SHA: ${it.gitSha}
Staging repository: ${it.nexusRepositoryUri}
""".trimIndent()
}
}
kotlinDslPluginOptions {
experimentalWarning.set(false)
}
dependencies {
testImplementation(platform("org.junit:junit-bom:5.7.0-M1"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
gradlePlugin {
plugins {
create("multiCache") {
id = "com.github.burrunan.multi-cache"
implementationClass = "com.github.burrunan.multicache.MulticachePlugin"
}
}
}
pluginBundle {
website = "https://github.com/burrunan/gradle-multi-cache"
vcsUrl = "https://github.com/burrunan/gradle-multi-cache"
description = "Multiple remote build cache nodes for Gradle"
tags = listOf("build-cache", "multiplex", "redundancy")
(plugins) {
"multiCache" {
id = "com.github.burrunan.multi-cache"
displayName = "Multiple remote build caches"
}
}
}
tasks.wrapper {
gradleVersion = "6.5.1"
distributionType = DistributionType.ALL
}
allprojects {
group = "com.github.burrunan.multicache"
version = buildVersion
tasks.configureEach<AbstractArchiveTask> {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
plugins.withId("java") {
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withSourcesJar()
if (!skipJavadoc) {
withJavadocJar()
}
}
apply(plugin = "maven-publish")
if (!enableGradleMetadata) {
tasks.configureEach<GenerateModuleMetadata> {
enabled = false
}
}
tasks {
configureEach<JavaCompile> {
options.encoding = "UTF-8"
}
afterEvaluate {
// Add default license/notice when missing (e.g. see :src:config that overrides LICENSE)
configureEach<Jar> {
CrLfSpec(LineEndings.LF).run {
into("META-INF") {
filteringCharset = "UTF-8"
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
textFrom("$rootDir/LICENSE")
textFrom("$rootDir/NOTICE")
}
}
}
}
configureEach<Jar> {
manifest {
attributes["Bundle-License"] = "Apache-2.0"
attributes["Implementation-Title"] = "Gradle Multi Cache"
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Gradle Multi Cache"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "Gradle Multi Cache"
attributes["Implementation-Vendor"] = "Gradle Multi Cache"
attributes["Implementation-Vendor-Id"] = "com.github.burrunan.multicache"
}
}
configureEach<Test> {
useJUnitPlatform()
// Keystore configuration for S3Mock server
systemProperty("server.ssl.key-store", "classpath:test_keystore.jks")
systemProperty("server.ssl.key-store-password", "password")
systemProperty("server.ssl.key-alias", "selfsigned")
systemProperty("server.ssl.key-password", "password")
// Pass the property to tests
fun passProperty(name: String, default: String? = null) {
val value = System.getProperty(name) ?: default
value?.let { systemProperty(name, it) }
}
passProperty("junit.jupiter.execution.parallel.enabled", "true")
passProperty("junit.jupiter.execution.parallel.mode.default", "concurrent")
passProperty("junit.jupiter.execution.timeout.default", "5 m")
}
}
tasks.configureEach<KotlinCompile> {
kotlinOptions {
jvmTarget = "1.8"
}
}
configure<PublishingExtension> {
publications {
if (project.path != ":") {
create<MavenPublication>(project.name) {
artifactId = project.name
version = rootProject.version.toString()
description = project.description
from(project.components.get("java"))
}
}
withType<MavenPublication> {
// if (!skipJavadoc) {
// Eager task creation is required due to
// https://github.com/gradle/gradle/issues/6246
// artifact(sourcesJar.get())
// artifact(javadocJar.get())
// }
// Use the resolved versions in pom.xml
// Gradle might have different resolution rules, so we set the versions
// that were used in Gradle build/test.
versionFromResolution()
pom {
simplifyXml()
// afterEvaluate is a workaround to add entries to plugin marker pom
afterEvaluate {
(project.findProperty("artifact.name") as? String)
?: "Gradle Multi Cache ${project.name.capitalize()}"
)
project.description
?: "Gradle Multi Cache ${project.name.capitalize()}"
)
}
developers {
developer {
id.set("vlsi")
name.set("Vladimir Sitnikov")
email.set("[email protected]")
}
}
inceptionYear.set("2020")
url.set("https://github.com/burrunan/gradle-multi-cache")
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("https://www.apache.org/licenses/LICENSE-2.0.txt")
comments.set("A business-friendly OSS license")
distribution.set("repo")
}
}
issueManagement {
system.set("GitHub")
url.set("https://github.com/burrunan/gradle-multi-cache/issues")
}
scm {
connection.set("scm:git:https://github.com/burrunan/gradle-multi-cache.git")
developerConnection.set("scm:git:https://github.com/burrunan/gradle-multi-cache.git")
url.set("https://github.com/burrunan/gradle-multi-cache")
tag.set("HEAD")
}
}
}
}
}
}
}