-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
126 lines (100 loc) · 3.1 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
plugins {
`maven-publish` // for JitPack
val kotlinVersion: String = System.getenv("KOTLIN_VERSION")?.takeIf { it.isNotEmpty() }
?: libs.versions.kotlin.get()
kotlin("jvm") version kotlinVersion
java
alias(libs.plugins.kotlinter)
}
// Since group cannot be obtained by generateKogeraVersion, it is defined as a constant.
val groupStr = "io.github.projectmapk"
val jacksonVersion = libs.versions.jackson.get()
val generatedSrcPath = "${layout.buildDirectory.get()}/generated/kotlin"
group = groupStr
version = "${jacksonVersion}-beta14"
repositories {
mavenCentral()
}
dependencies {
val kotlinVersion: String = System.getenv("KOTLIN_VERSION")?.takeIf { it.isNotEmpty() }
?: libs.versions.kotlin.get()
implementation("${libs.kotlin.stdlib.get()}:${kotlinVersion}")
implementation(libs.kotlinx.metadata.jvm)
api(libs.jackson.databind)
api(libs.jackson.annotations)
// test libs
testImplementation("${libs.kotlin.reflect.get()}:${kotlinVersion}")
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testRuntimeOnly(libs.junit.engine)
testImplementation(libs.mockk)
testImplementation(libs.jackson.xml)
testImplementation(libs.jackson.jsr310)
}
kotlin {
explicitApi()
// for PackageVersion
sourceSets["main"].apply {
kotlin.srcDir(generatedSrcPath)
}
val useK2 = System.getenv("KOTLIN_VERSION")?.takeIf { it.isNotEmpty() }
?.let { it.toBoolean() } ?: false
sourceSets.all {
languageSettings {
if (useK2) {
languageVersion = "2.0"
}
}
}
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks {
// For ported tests, they are excluded from the formatting because they are not new code.
lintKotlinTest {
exclude { it.path.contains("zPorted") }
}
formatKotlinTest {
exclude { it.path.contains("zPorted") }
}
// Task to generate version file
val generateKogeraVersion by registering(Copy::class) {
val packageStr = "$groupStr.jackson.module.kogera"
from(
resources.text.fromString(
"""
package $packageStr
import com.fasterxml.jackson.core.Version
import com.fasterxml.jackson.core.util.VersionUtil
public val kogeraVersion: Version = VersionUtil.parseVersion("$version", "$groupStr", "${rootProject.name}")
""".trimIndent()
)
) {
rename { "KogeraVersion.kt" }
}
into(file("$generatedSrcPath/${packageStr.replace(".", "/")}"))
}
// Added to avoid failure in generating dependency graphs in CI.
lintKotlinMain {
dependsOn.add(generateKogeraVersion)
}
compileKotlin {
dependsOn.add(generateKogeraVersion)
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
test {
useJUnitPlatform()
}
}
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
}
}
}