-
-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
130 lines (115 loc) · 3.86 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
130 lines (115 loc) · 3.86 KB
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
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile
import java.time.ZonedDateTime
import java.time.format.DateTimeFormatter
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.dokka) apply false
alias(libs.plugins.ktlint)
alias(libs.plugins.maven.publish) apply false
alias(libs.plugins.plugin.publish) apply false
alias(libs.plugins.versions)
alias(libs.plugins.license)
`java-gradle-plugin`
`java-library`
groovy
idea
}
tasks.withType<Wrapper>().configureEach {
distributionType = Wrapper.DistributionType.ALL
}
idea {
module {
isDownloadSources = true
isDownloadJavadoc = true
}
}
subprojects {
// Pin the Java/Kotlin toolchain to JDK 17 (AGP 9 / Gradle 9 minimum) so compilation, tests and
// IDE analysis use a consistent JDK regardless of the JDK used to launch Gradle.
pluginManager.withPlugin("org.jetbrains.kotlin.jvm") {
kotlin {
jvmToolchain(17)
}
}
tasks.withType<Jar>().configureEach {
val dateFile =
layout.buildDirectory
.file("jar-manifest-date.txt")
.get()
.asFile
if (!dateFile.exists()) {
val date =
DateTimeFormatter
.ofPattern("EEE MMM dd HH:mm:ss zzz yyyy")
.format(ZonedDateTime.now())
dateFile.parentFile.mkdirs()
dateFile.writeText(date.trim())
}
manifest {
attributes(
"Created-By" to project.property("POM_DEVELOPER_NAME") as String,
"Implementation-Title" to project.property("POM_NAME") as String,
"Implementation-Version" to project.property("VERSION_NAME") as String,
"Implementation-Vendor" to project.property("POM_DEVELOPER_NAME") as String,
"Built-By" to System.getProperty("user.name"),
"Built-Date" to dateFile.readText().trim(),
"Built-JDK" to System.getProperty("java.version"),
"Built-Gradle" to project.gradle.gradleVersion,
)
}
}
tasks.withType<KotlinJvmCompile>().configureEach {
compilerOptions {
jvmTarget.set(JvmTarget.JVM_17)
languageVersion.set(KotlinVersion.KOTLIN_2_4)
apiVersion.set(KotlinVersion.KOTLIN_2_4)
freeCompilerArgs.add("-progressive")
freeCompilerArgs.add("-Xjsr305=strict")
freeCompilerArgs.add("-Xemit-jvm-type-annotations")
freeCompilerArgs.add("-Xassertions=jvm")
freeCompilerArgs.add("-jvm-default=enable")
}
}
tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
options.apply {
compilerArgs.add("-Xlint:all")
compilerArgs.add("-Xlint:-options")
encoding = "utf-8"
isFork = true
}
}
tasks.withType<GroovyCompile>().configureEach {
sourceCompatibility = JavaVersion.VERSION_17.toString()
targetCompatibility = JavaVersion.VERSION_17.toString()
options.apply {
compilerArgs.add("-Xlint:all")
compilerArgs.add("-Xlint:-options")
encoding = "utf-8"
isFork = true
}
}
tasks.withType<Test>().configureEach {
useJUnitPlatform() // Ensure JUnit Platform is used if you are using JUnit 5 or Spock 2.x
testLogging {
exceptionFormat = TestExceptionFormat.FULL
showCauses = true
showExceptions = true
showStackTraces = true
// Check if running on CI and set events accordingly
events =
if (System.getenv("CI") != null) {
TestLogEvent.entries.toSet()
} else {
setOf(TestLogEvent.FAILED, TestLogEvent.SKIPPED)
}
}
val maxWorkerCount = project.gradle.startParameter.maxWorkerCount
maxParallelForks = if (maxWorkerCount < 2) 1 else maxWorkerCount / 2
}
}