-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.gradle
144 lines (119 loc) · 3.93 KB
/
build.gradle
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
plugins {
id "java"
id "org.jetbrains.kotlin.jvm" version "1.7.21"
id "antlr"
id "maven-publish"
id "idea"
}
repositories {
mavenCentral()
}
configurations {
// for putting Error Prone javac in bootclasspath for running tests
errorproneJavac
// Do not include whole antlr tool in jar
// https://github.com/gradle/gradle/issues/820#issuecomment-288838412
compile {
extendsFrom = extendsFrom.findAll { it != configurations.antlr }
}
}
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
compileKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "11"
}
}
ext {
versions = [
kotlin : "1.7.21",
antlr4 : "4.11.1",
checkerFramework : "3.28.0",
errorproneJavacVersion: "9+181-r4173-1",
junit : "4.13.2",
]
}
generateGrammarSource {
outputDirectory = new File("src/main/java")
}
// Generate parser, then compile with kotlin, and then with java
compileKotlin.dependsOn generateGrammarSource
compileTestKotlin.dependsOn generateGrammarSource
compileJava.dependsOn compileKotlin
sourceSets {
main {
java {
srcDirs = ["src/main/java"]
}
kotlin {
srcDirs = ["src/main/java", "src/main/kotlin"]
}
resources {
srcDirs = ["src/main/resources"]
}
}
}
tasks.withType(JavaCompile) {
classpath += files("build/classes/kotlin/main")
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin}"
antlr "org.antlr:antlr4:${versions.antlr4}"
compile "org.antlr:antlr4-runtime:${versions.antlr4}"
implementation "org.checkerframework:checker:${versions.checkerFramework}"
implementation "org.checkerframework:checker-qual:${versions.checkerFramework}"
compileOnly "com.google.errorprone:javac:${versions.errorproneJavacVersion}"
// Testing
testImplementation "junit:junit:${versions.junit}"
testImplementation "org.jetbrains.kotlin:kotlin-test-junit:${versions.kotlin}"
testImplementation "org.checkerframework:framework-test:${versions.checkerFramework}"
errorproneJavac "com.google.errorprone:javac:${versions.errorproneJavacVersion}"
}
jar {
from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
task buildJar(type: Copy) {
from jar
into "dist"
}
tasks.withType(JavaCompile).all {
options.compilerArgs.add("-Xlint:all")
}
test {
testLogging.showStandardStreams = true
inputs.files("tests")
if (!JavaVersion.current().java9Compatible) {
jvmArgs "-Xbootclasspath/p:${configurations.errorproneJavac.asPath}"
} else {
// A list of add-export and add-open arguments to be used when running the Checker Framework.
// Keep this list in sync with the list in the Checker Framework manual.
var compilerArgsForRunningCF = [
// 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",
// Required because the Checker Framework reflectively accesses private members in com.sun.tools.javac.comp.
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
]
jvmArgs += compilerArgsForRunningCF
}
}
clean.doFirst {
delete "${rootDir}/tests/build/"
}