-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
276 lines (233 loc) · 7.27 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import java.nio.charset.StandardCharsets
val rootPackage = "xyz.leutgeb.lorenz.atlas"
val rootPackagePath = rootPackage.replace(".", "/")
project.setProperty("mainClassName", "$rootPackage.Main")
fun run(command: String, workingDir: File = file("./")): String {
val parts = command.split("\\s".toRegex())
val proc = ProcessBuilder(*parts.toTypedArray())
.directory(workingDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
proc.waitFor(1, TimeUnit.MINUTES)
return proc.inputStream.bufferedReader().readText().trim()
}
plugins {
java
application
antlr
jacoco
id("com.diffplug.spotless") version "6.0.0"
id("com.github.jk1.dependency-license-report") version "2.0"
id("com.github.johnrengelman.shadow") version "7.1.2"
id("org.ajoberstar.reckon") version "0.16.1"
id("org.graalvm.buildtools.native") version "0.9.16"
}
repositories {
mavenCentral {
metadataSources {
mavenPom()
}
}
mavenCentral {
metadataSources {
artifact()
}
}
}
buildscript {
dependencyLocking {
lockAllConfigurations()
}
}
dependencyLocking {
lockAllConfigurations()
}
reckon {
scopeFromProp()
stageFromProp("rc")
}
task("printVersion") {
doLast { println(project.version) }
}
// See https://github.com/gradle/gradle/issues/820
configurations[JavaPlugin.API_CONFIGURATION_NAME].let { apiConfiguration ->
apiConfiguration.setExtendsFrom(
apiConfiguration.extendsFrom.filter {
it.name != "antlr"
}
)
}
configurations.all {
resolutionStrategy {
force("org.antlr:antlr4-runtime:4.9.3")
force("org.antlr:antlr4-tool:4.9.3")
}
}
dependencies {
val antlrVersion = "4.9.3"
antlr("org.antlr:antlr4:$antlrVersion")
compileOnly("org.antlr:antlr4:$antlrVersion")
runtimeOnly("org.antlr:antlr4-runtime:$antlrVersion")
implementation("com.google.guava:guava:31.0.1-jre")
implementation("org.hipparchus:hipparchus-core:1.8")
// Lombok
val lombok = "org.projectlombok:lombok:1.18.22"
compileOnly(lombok)
testCompileOnly(lombok)
annotationProcessor(lombok)
// Graphs
fun jgrapht(x: String): String {
return "org.jgrapht:jgrapht-$x:1.5.0"
}
implementation(jgrapht("core"))
implementation(jgrapht("io"))
// Commandline Parameters
implementation("info.picocli:picocli:4.6.2")
annotationProcessor("info.picocli:picocli-codegen:4.6.2")
// Testing
implementation(enforcedPlatform("org.junit:junit-bom:5.8.1"))
fun jupiter(x: String): String {
return "org.junit.jupiter:junit-jupiter$x:5.8.1"
}
testImplementation(jupiter("-params"))
testRuntimeOnly(jupiter(""))
testImplementation("tech.tablesaw:tablesaw-core:0.42.0")
// The Z3 Theorem Prover
implementation("org.sosy-lab:javasmt-solver-z3:4.8.12:com.microsoft.z3@jar")
// Graph output
implementation("guru.nidi:graphviz-java:0.18.1") {
// NOTE: Somehow JUnit ends up on the classpath...
exclude("org.junit.platform")
exclude(group = "net.arnx", module = "nashorn-promise")
exclude(group = "org.webjars.npm", module = "viz.js-for-graphviz-java")
}
// Logging
implementation("org.slf4j:slf4j-simple:1.7.32")
// Native Image
compileOnly("org.graalvm.nativeimage:svm:21.3.0")
implementation("io.github.classgraph:classgraph:4.8.133")
// JSON Binding
// See https://javaee.github.io/jsonb-spec/getting-started.html
// implementation("javax.json.bind:javax.json.bind-api:1.0")
// implementation("org.eclipse:yasson:1.0")
// JSON Processing
// See https://javaee.github.io/jsonp/getting-started.html
implementation("jakarta.json:jakarta.json-api:2.0.0")
implementation("org.glassfish:jakarta.json:2.0.0")
}
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
tasks.withType<AntlrTask> {
// See https://github.com/antlr/antlr4/blob/master/doc/tool-options.md
arguments.addAll(
arrayOf(
"-visitor",
"-no-listener",
"-long-messages",
"-package", "$rootPackage.antlr",
"-Werror",
"-Xlog",
"-lib", "src/main/antlr/$rootPackagePath/antlr",
"-encoding", "UTF-8"
)
)
}
val atlasDir = "build/generated-src/atlas/main"
sourceSets {
main {
java {
srcDir(atlasDir)
}
}
}
tasks.create<JavaExec>("generateExamples") {
dependsOn("compileJava")
classpath = project.sourceSets["main"].runtimeClasspath
mainClass.set("$rootPackage.Main")
args("--search=src/test/resources/examples", "java", ".*", atlasDir)
}
tasks.withType<JavaCompile> {
options.encoding = StandardCharsets.UTF_8.name()
options.compilerArgs.addAll(arrayOf("--enable-preview", "-Xlint:unchecked", "-Xlint:deprecation", "-Aproject=atlas", "-Averbose=true"))
}
tasks.test {
useJUnitPlatform()
testLogging {
events("failed")
showStackTraces = true
exceptionFormat = TestExceptionFormat.FULL
showStandardStreams = true
}
}
application {
mainClass.set("$rootPackage.Main")
}
tasks.create<JavaCompile>("compileGeneratedJava") {
dependsOn("generateExamples")
source = fileTree(buildDir.resolve("generated-src/atlas/main"))
classpath = project.configurations.compileClasspath.get() + sourceSets.main.get().output
destinationDirectory.set(sourceSets.main.get().output.classesDirs.singleFile)
}
tasks.shadowJar {
// Code generation is broken as of 2022-04
// dependsOn("compileGeneratedJava")
archiveClassifier.set("shadow")
manifest {
attributes["Main-Class"] = "$rootPackage.Main"
}
}
graalvmNative {
binaries {
named("main") {
imageName.set("atlas")
mainClass.set("$rootPackage.Main")
sharedLibrary.set(false)
fallback.set(false)
verbose.set(true)
buildArgs.addAll(
"-H:Log=registerResource",
"-H:+ReportExceptionStackTraces",
"-H:+PrintClassInitialization",
"--report-unsupported-elements-at-runtime"
)
javaLauncher.set(
javaToolchains.launcherFor {
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.matching("GraalVM"))
}
)
}
}
}
spotless {
java {
googleJavaFormat("1.13.0")
target("src/**/*.java")
}
kotlinGradle {
ktlint()
target("build.gradle.kts")
}
}
tasks.jacocoTestReport {
reports {
xml.required.set(true)
html.required.set(true)
}
// NOTE: Contents of the antlr subpackage are autogenerated.
classDirectories.setFrom(
sourceSets.main.get().output.asFileTree.matching {
exclude("**/xyz/leutgeb/lorenz/atlas/antlr/**")
}
)
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
}
tasks.jacocoTestReport {
dependsOn(tasks.test) // tests are required to run before generating the report
}