-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
107 lines (95 loc) · 2.93 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
kotlin("jvm") version "1.9.21"
kotlin("plugin.serialization") version "1.9.21"
id("maven-publish")
jacoco
}
group = "com.github.milkcocoa0902"
version = "0.2.3"
java.sourceCompatibility = JavaVersion.VERSION_11
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "11"
}
}
repositories {
mavenCentral()
maven(url = "https://plugins.gradle.org/m2/")
}
val ktlint by configurations.creating
dependencies {
api(libs.kotlin.serialization.core)
implementation(libs.kotlin.serialization.json)
implementation(libs.kotlin.serialization.properties)
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter)
testImplementation(libs.mockk)
ktlint("com.pinterest.ktlint:ktlint-cli:1.1.0") {
attributes {
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
}
}
}
tasks.test {
useJUnitPlatform()
// https://github.com/mockk/mockk/issues/681
jvmArgs("--add-opens", "java.base/java.time=ALL-UNNAMED")
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
reports {
xml.required = true
csv.required = false
html.outputLocation = layout.buildDirectory.dir("jacocoHtml")
}
}
jacoco {
toolVersion = "0.8.9"
reportsDirectory = layout.buildDirectory.dir("jacocoReport")
}
afterEvaluate {
publishing {
publications {
// Creates a Maven publication called "release".
register(components.first().name, MavenPublication::class) {
from(components.first())
groupId = "com.github.milkcocoa0902"
artifactId = "colotok"
version = version
}
}
}
}
val ktlintCheck by tasks.registering(JavaExec::class) {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Check Kotlin code style"
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
// see https://pinterest.github.io/ktlint/install/cli/#command-line-usage for more information
args(
"**/src/**/*.kt",
"**.kts",
"!**/build/**"
)
}
tasks.check {
dependsOn(ktlintCheck)
}
tasks.register<JavaExec>("ktlintFormat") {
group = LifecycleBasePlugin.VERIFICATION_GROUP
description = "Check Kotlin code style and format"
classpath = ktlint
mainClass.set("com.pinterest.ktlint.Main")
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
// see https://pinterest.github.io/ktlint/install/cli/#command-line-usage for more information
args(
"-F",
"**/src/**/*.kt",
"**.kts",
"!**/build/**"
)
}