-
Notifications
You must be signed in to change notification settings - Fork 12
/
build.gradle.kts
50 lines (43 loc) · 1.43 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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import java.io.ByteArrayOutputStream
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ktlint)
alias(libs.plugins.kotlin.serialization)
}
val projectVersion: String = run {
val rawVersion = file("version").readLines().first()
if (project.hasProperty("rawVersion")) {
rawVersion
} else {
val branch = System.getenv("VCS_BRANCH")?.replace('/', '-') ?: "unknown-branch"
System.getenv("BUILD_NUMBER")?.let { buildNumber ->
val gitRev = ByteArrayOutputStream()
exec {
commandLine("git", "rev-parse", "--short", "HEAD")
standardOutput = gitRev
}.assertNormalExitValue()
rawVersion.replace("SNAPSHOT", "BETA$buildNumber-$branch-${gitRev.toString().trim()}")
} ?: rawVersion
}
}
logger.warn("Resolved project version $projectVersion")
allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "java-library")
group = "org.anvilpowered"
version = projectVersion
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
freeCompilerArgs = listOf(
"-opt-in=kotlin.RequiresOptIn",
"-Xcontext-receivers",
)
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
}