-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
57 lines (47 loc) · 1.59 KB
/
build.gradle.kts
File metadata and controls
57 lines (47 loc) · 1.59 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
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
plugins {
alias(libs.plugins.kotlin.jvm)
alias(libs.plugins.ktlint)
alias(libs.plugins.kotlin.serialization)
}
val rawVersion: Provider<String> = providers.fileContents(layout.projectDirectory.file("version")).asText.map { it.trim() }
val vcsBuildVersion: Provider<String> =
provider {
System.getenv("VCS_BRANCH")?.replace('/', '-') ?: "unknown-branch"
}.flatMap { branch ->
System.getenv("BUILD_NUMBER")?.let { buildNumber ->
providers
.exec {
commandLine("git", "rev-parse", "--short", "HEAD")
}.standardOutput.asText
.flatMap { gitRev ->
rawVersion.map { it.replace("SNAPSHOT", "BETA$buildNumber-$branch-${gitRev.trim()}") }
}
} ?: rawVersion
}
val isRawVersion: Provider<Boolean> = provider { project.hasProperty("rawVersion") }
val projectVersion: Provider<String> =
isRawVersion.zip(
rawVersion.zip(vcsBuildVersion) { raw, build -> raw to build },
) { isRaw, versions -> if (isRaw) versions.first else versions.second }
logger.warn("Resolved project version ${projectVersion.get()}")
allprojects {
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "java-library")
group = "org.anvilpowered"
version = projectVersion.get()
kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_21
freeCompilerArgs =
listOf(
"-opt-in=kotlin.RequiresOptIn",
"-Xcontext-receivers",
)
}
}
java {
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
}
}