-
Notifications
You must be signed in to change notification settings - Fork 18
/
build.gradle.kts
278 lines (253 loc) · 10.8 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
276
277
278
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
import java.util.*
plugins {
`maven-publish`
`kotlin-dsl`
id("com.gradle.plugin-publish") version "1.3.0"
id("com.github.vlsi.crlf") version "1.90"
id("com.github.vlsi.gradle-extensions") version "1.90"
id("com.github.vlsi.stage-vote-release") version "1.90"
}
repositories {
mavenCentral()
}
val String.v: String get() = rootProject.extra["$this.version"] as String
val buildVersion = "current".v + releaseParams.snapshotSuffix
println("Building gradle-s3-build-cache $buildVersion")
val enableGradleMetadata by props()
val autostyleSelf by props()
val skipAutostyle by props()
val skipJavadoc by props()
val buildJdk by props.int
val targetJdk by props.int
val testJdk by props.int
releaseParams {
tlp.set("gradle-s3-build-cache")
organizationName.set("burrunan")
componentName.set("gradle-s3-build-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()
}
}
dependencies {
constraints {
implementation("org.apache.httpcomponents:httpclient:4.5.14") {
because("httpclient 4.5.13 fails to verify *.s3.amazonaws.com certificates, see https://github.com/burrunan/gradle-s3-build-cache/issues/23")
}
}
implementation(platform("software.amazon.awssdk:bom:2.28.27"))
implementation("software.amazon.awssdk:sso") {
because("Needed to automatically enable AWS SSO login, see https://stackoverflow.com/a/67824174")
}
implementation ("software.amazon.awssdk:ssooidc") {
because("Needed to automatically enable AWS SSO login, see https://stackoverflow.com/a/67824174")
}
implementation("software.amazon.awssdk:s3") {
// We do not use netty client so far
exclude("software.amazon.awssdk", "netty-nio-client")
}
runtimeOnly("software.amazon.awssdk:sts")
testImplementation(platform("org.junit:junit-bom:5.11.3"))
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("org.junit.jupiter:junit-jupiter-params")
testImplementation("com.adobe.testing:s3mock-junit5:2.17.0") {
// Gradle has its own logging
exclude("ch.qos.logback", "logback-classic")
exclude("org.apache.logging.log4j", "log4j-to-slf4j")
exclude("org.slf4j", "jul-to-slf4j")
}
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}
gradlePlugin {
website.set("https://github.com/burrunan/gradle-s3-build-cache")
vcsUrl.set("https://github.com/burrunan/gradle-s3-build-cache")
plugins {
create("s3BuildCache") {
id = "com.github.burrunan.s3-build-cache"
tags.set(listOf("build-cache", "s3"))
displayName = "AWS S3 build cache"
description = "An AWS S3 build cache implementation"
implementationClass = "com.github.burrunan.s3cache.AwsS3Plugin"
}
}
}
tasks.wrapper {
gradleVersion = "8.10.2"
distributionType = DistributionType.BIN
}
allprojects {
group = "com.github.burrunan.s3cache"
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 {
toolchain {
languageVersion.set(JavaLanguageVersion.of(buildJdk))
}
withSourcesJar()
if (!skipJavadoc) {
withJavadocJar()
}
}
apply(plugin = "maven-publish")
if (!enableGradleMetadata) {
tasks.configureEach<GenerateModuleMetadata> {
enabled = false
}
}
tasks {
configureEach<JavaCompile> {
options.encoding = "UTF-8"
options.release.set(targetJdk)
}
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 S3 Build Cache"
attributes["Implementation-Version"] = project.version
attributes["Specification-Vendor"] = "Gradle S3 Build Cache"
attributes["Specification-Version"] = project.version
attributes["Specification-Title"] = "Gradle S3 Build Cache"
attributes["Implementation-Vendor"] = "Gradle S3 Build Cache"
attributes["Implementation-Vendor-Id"] = "com.github.burrunan.s3cache"
}
}
configureEach<Test> {
useJUnitPlatform()
javaLauncher.set(
project.javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(testJdk))
}
)
// 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 {
val jdkRelease = if (targetJdk < 9) "1.8" else targetJdk.toString()
jvmTarget = jdkRelease
freeCompilerArgs += "-Xjdk-release=$jdkRelease"
}
}
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 {
val defaultName = "Gradle S3 Build Cache ${project.name.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(
Locale.getDefault()
) else it.toString()
}}"
(project.findProperty("artifact.name") as? String)
?: defaultName
)
project.description
?: defaultName
)
}
developers {
developer {
id.set("vlsi")
name.set("Vladimir Sitnikov")
email.set("[email protected]")
}
}
inceptionYear.set("2020")
url.set("https://github.com/burrunan/gradle-s3-build-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-s3-build-cache/issues")
}
scm {
connection.set("scm:git:https://github.com/burrunan/gradle-s3-build-cache.git")
developerConnection.set("scm:git:https://github.com/burrunan/gradle-s3-build-cache.git")
url.set("https://github.com/burrunan/gradle-s3-build-cache")
tag.set("HEAD")
}
}
}
}
}
}
}