-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
230 lines (194 loc) · 7.29 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import com.github.gradle.node.task.NodeTask
import org.gradle.api.JavaVersion.*
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.nodeGradle)
alias(libs.plugins.nexusPublish)
antlr
signing
`maven-publish`
}
group = "dev.kensa"
version = project.properties["releaseVersion"] ?: "SNAPSHOT"
fun createSourceSet(name: String) {
sourceSets {
create(name) {
compileClasspath += sourceSets.main.get().output + sourceSets.test.get().output
runtimeClasspath += sourceSets.main.get().output + sourceSets.test.get().output
}
}
}
createSourceSet("junitIntegrationTest")
val junitIntegrationTestImplementation: Configuration by configurations.getting { extendsFrom(configurations.implementation.get()) }
createSourceSet("javaExampleTest")
val javaExampleTestImplementation: Configuration by configurations.getting { extendsFrom(configurations.implementation.get()) }
createSourceSet("kotlinExampleTest")
val kotlinExampleTestImplementation: Configuration by configurations.getting { extendsFrom(configurations.implementation.get()) }
nexusPublishing {
val nexusUsername: String? by project
val nexusPassword: String? by project
repositories {
sonatype {
username = nexusUsername
password = nexusPassword
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
repositories {
mavenCentral()
}
dependencies {
antlr(libs.antlr)
api(libs.kotlinStdLib)
api(libs.kotlinReflect)
implementation(libs.kotlinCoroutines)
implementation(libs.junitJupiterParams)
implementation(libs.junitJupiterApi)
implementation(libs.junitJupiterEngine)
implementation(libs.assertJCore)
implementation(libs.hamcrestCore)
implementation(libs.awaitilityKotlin)
implementation(libs.minimalJson)
implementation(libs.plantuml)
implementation(libs.pebble)
implementation(libs.kotestAssertionsCoreJvm)
testImplementation(libs.mockitoKotlin)
testImplementation(libs.kotlinCoroutinesTest)
junitIntegrationTestImplementation(libs.junitPlatformTestKit)
junitIntegrationTestImplementation(libs.junitPlatformLauncher)
javaExampleTestImplementation(libs.junitPlatformTestKit)
javaExampleTestImplementation(libs.junitPlatformLauncher)
kotlinExampleTestImplementation(libs.junitPlatformTestKit)
kotlinExampleTestImplementation(libs.junitPlatformLauncher)
}
node {
version = libs.versions.node.get()
download = true
}
tasks {
javadoc {
options {
this as StandardJavadocDocletOptions
addBooleanOption("Xdoclint:none", true)
addStringOption("Xmaxwarns", "1")
}
}
register<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(project.the<SourceSetContainer>()["main"].allSource)
dependsOn(classes)
}
register<Jar>("javadocJar") {
archiveClassifier.set("javadoc")
javadoc.get().destinationDir
dependsOn(javadoc)
}
withType<KotlinCompile> {
dependsOn("generateGrammarSource")
kotlinOptions {
jvmTarget = "17"
freeCompilerArgs += listOf("-Xjvm-default=all", "-opt-in=kotlin.contracts.ExperimentalContracts")
}
}
java {
sourceCompatibility = VERSION_17
targetCompatibility = VERSION_17
}
withType<AntlrTask> {
outputDirectory = file("$outputDirectory/dev/kensa/parse")
arguments = arguments + listOf("-listener", "-no-visitor", "-package", "dev.kensa.parse")
}
register<Test>("junitIntegrationTest") {
useJUnitPlatform {
exclude("dev/kensa/example/**")
}
description = "Runs JUnit integration tests."
group = "verification"
testClassesDirs = sourceSets["junitIntegrationTest"].output.classesDirs
classpath = sourceSets["junitIntegrationTest"].runtimeClasspath
shouldRunAfter("test")
}
register<Test>("kotlinExampleTest") {
useJUnitPlatform {
exclude("dev/kensa/example/**")
}
description = "Runs Kotlin example tests."
group = "verification"
testClassesDirs = sourceSets["kotlinExampleTest"].output.classesDirs
classpath = sourceSets["kotlinExampleTest"].runtimeClasspath
shouldRunAfter("junitIntegrationTest")
}
register<Test>("javaExampleTest") {
useJUnitPlatform {
exclude("dev/kensa/example/**")
}
description = "Runs Java example tests."
group = "verification"
testClassesDirs = sourceSets["javaExampleTest"].output.classesDirs
classpath = sourceSets["javaExampleTest"].runtimeClasspath
shouldRunAfter("junitIntegrationTest")
}
check { dependsOn("junitIntegrationTest", "kotlinExampleTest", "javaExampleTest") }
withType<Test> {
useJUnitPlatform {
exclude("dev/kensa/example/**")
}
}
register<NodeTask>("webpack") {
script = project.file("node_modules/.bin/webpack")
inputs.file("webpack.config.js")
inputs.file("package-lock.json")
inputs.dir("src/ui")
outputs.dir("$buildDir/resources/main")
dependsOn("npmInstall")
}
register<NodeTask>("startUiDevServer") {
script = project.file("node_modules/.bin/webpack-dev-server")
args = listOf("--mode", "development")
inputs.file("webpack.config.js")
inputs.file("package-lock.json")
inputs.dir("src/ui")
outputs.dir("$buildDir/resources/main")
dependsOn("npmInstall")
}
processResources {
dependsOn("webpack")
}
}
publishing {
publications {
create<MavenPublication>("mavenJava") {
artifactId = "kensa"
pom.withXml {
asNode().appendNode("name", "kensa")
asNode().appendNode("description", description)
asNode().appendNode("url", "https://kensa.dev")
asNode().appendNode("developers")
.appendNode("developer").appendNode("name", "Paul Brooks").parent()
.appendNode("email", "[email protected]")
asNode().appendNode("scm")
.appendNode("url", "[email protected]:kensa-dev/kensa.git").parent()
.appendNode("connection", "scm:git:[email protected]:kensa-dev/kensa.git").parent()
.appendNode("developerConnection", "scm:git:[email protected]:kensa-dev/kensa.git")
asNode().appendNode("licenses").appendNode("license")
.appendNode("name", "Apache License, Version 2.0").parent()
.appendNode("url", "http://www.apache.org/licenses/LICENSE-2.0.html")
}
from(components["java"])
artifact(tasks["sourcesJar"])
artifact(tasks["javadocJar"])
}
}
}
if (project.findProperty("sign") == "true") {
signing {
val signingKeyId: String? by project
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}
}