-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle.kts
164 lines (135 loc) · 5.53 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
import org.jetbrains.gradle.ext.compiler
import org.jetbrains.gradle.ext.settings
import org.checkerframework.gradle.plugin.CheckerFrameworkExtension
plugins {
id("java")
id("checkstyle")
id("com.diffplug.spotless") version Versions.SPOTLESS
id("org.jetbrains.gradle.plugin.idea-ext") version Versions.IDEA_EXT
id("com.github.johnrengelman.shadow") version Versions.SHADOW
id("org.checkerframework") version Versions.CF_PLUGIN
}
apply(plugin = "org.checkerframework")
group = "org.uniflow"
version = "1.0-SNAPSHOT"
val compilerArgsForJavacModules by extra(arrayOf(
// These are required in Java 16+ because the --illegal-access option is set to deny
// by default. None of these packages are accessed via reflection, so the module
// only needs to be exported, but not opened.
"--add-exports", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"--add-exports", "jdk.compiler/com.sun.tools.javac.resources=ALL-UNNAMED",
))
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.eisop:javacutil:${Versions.CHECKER_FRAMEWORK}")
implementation("io.github.eisop:dataflow:${Versions.CHECKER_FRAMEWORK}")
implementation("io.github.eisop:checker-qual:${Versions.CHECKER_FRAMEWORK}")
implementation("com.google.guava:guava:${Versions.GUAVA}") {
exclude(group = "org.checkerframework", module = "checker-qual")
}
annotationProcessor("com.google.auto.value:auto-value:${Versions.AUTO_VALUE}")
compileOnly("com.google.auto.value:auto-value-annotations:${Versions.AUTO_VALUE}")
annotationProcessor("com.google.auto.service:auto-service:${Versions.AUTO_SERVICE}")
compileOnly("com.google.auto.service:auto-service-annotations:${Versions.AUTO_SERVICE}")
implementation("info.picocli:picocli:${Versions.PICOCLI}")
implementation("ch.qos.logback:logback-core:${Versions.LOGBACK}")
implementation("ch.qos.logback:logback-classic:${Versions.LOGBACK}")
implementation("org.slf4j:slf4j-api:${Versions.SLF4J}")
// AFU is an "includedBuild" imported in settings.gradle.kts, so the version number doesn"t matter.
// https://docs.gradle.org/current/userguide/composite_builds.html#settings_defined_composite
implementation("io.github.eisop:annotation-file-utilities:*") {
exclude(group = "com.google.errorprone", module = "javac")
}
implementation("org.ow2.sat4j:org.ow2.sat4j.core:${Versions.SAT4J}")
implementation("org.ow2.sat4j:org.ow2.sat4j.maxsat:${Versions.SAT4J}")
testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT}")
}
allprojects {
tasks.withType<JavaCompile> {
// Setting `sourceCompatibility` as a temporary fix for
// an unsolved gradle issue: https://github.com/gradle/gradle/issues/18824
sourceCompatibility = "17"
options.compilerArgs.addAll(compilerArgsForJavacModules)
options.isFork = true
options.forkOptions.jvmArgs = (options.forkOptions.jvmArgs ?: listOf()).plus(compilerArgsForJavacModules)
}
tasks.withType<Test> {
val args = jvmArgs ?: mutableListOf()
args.addAll(compilerArgsForJavacModules)
jvmArgs = args
}
}
tasks.shadowJar {
description = "Creates a fat JAR"
dependencies {
exclude(dependency("junit:.*:.*"))
}
manifest {
attributes["Description"] = "UniFlow"
attributes["Main-Class"] = "org.uniflow.InferenceMain"
}
archiveFileName.set("uniflow.jar")
destinationDirectory.set(file("${projectDir}/bin"))
}
idea.project.settings {
compiler {
javac {
// forces Intellij IDEA to recognize the extra compiler args
javacAdditionalOptions = compilerArgsForJavacModules.joinToString(" ")
}
}
}
// NOTE: make sure to run spotless under java 17 or later
spotless {
format("misc") {
// define the files to apply `misc` to
target("*.gradle", "*.md", ".gitignore")
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
googleJavaFormat(Versions.GOOGLE_JAVA_FORMAT).aosp().reflowLongStrings()
importOrder("com", "jdk", "lib", "org", "java", "javax")
}
}
checkstyle {
toolVersion = Versions.CHECKSTYLE
}
tasks.withType<Checkstyle> {
reports {
// disable reporting to files
xml.required.set(false)
html.required.set(false)
}
}
configure<CheckerFrameworkExtension> {
excludeTests = true
// temporarily disable
checkers = listOf(
// "org.checkerframework.checker.nullness.NullnessChecker"
)
extraJavacArgs = listOf(
"-AskipDefs=^.*AutoValue_.*$" // don't check generated AutoValues
)
}
tasks.test {
useJUnitPlatform()
}
// TODO: find cyclic dependencies between classes that are stored in Context, as they may cause infinite recursion