-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuild.gradle
More file actions
194 lines (164 loc) · 5.57 KB
/
build.gradle
File metadata and controls
194 lines (164 loc) · 5.57 KB
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
plugins {
id("application")
id("java-library")
id("maven-publish")
id("signing")
id("com.diffplug.spotless").version("6.25.0")
id("org.checkerframework").version("0.6.49")
id("net.ltgt.errorprone").version("4.1.0")
id("com.adarshr.test-logger").version("4.0.0")
}
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
mavenLocal()
}
application {
mainClass = "org.checkerframework.specimin.SpeciminRunner"
}
dependencies {
implementation("com.github.javaparser:javaparser-symbol-solver-core:3.27.1")
implementation("net.sf.jopt-simple:jopt-simple:5.0.4")
implementation("org.vineflower:vineflower:1.11.0")
implementation("commons-io:commons-io:2.21.0")
// Use JUnit test framework.
testImplementation("junit:junit:4.13.2")
errorprone("com.google.errorprone:error_prone_core:2.35.1")
}
// Use require-javadoc. From https://github.com/plume-lib/require-javadoc.
configurations {
requireJavadoc
}
dependencies {
requireJavadoc("org.plumelib:require-javadoc:2.0.0")
}
tasks.register("requireJavadoc", JavaExec) {
group = "Documentation"
description = "Ensures that Javadoc documentation exists."
mainClass = "org.plumelib.javadoc.RequireJavadoc"
classpath = configurations.requireJavadoc
args("src/main/java")
jvmArgs += [
'--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-exports=jdk.compiler/com.sun.tools.javac.parser=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-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED',
'--add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED',
]
}
tasks.register("expectedTestOutputsMustCompile", Exec) {
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
commandLine("cmd", "/c", "typecheck_test_outputs.bat")
} else {
commandLine("sh", "typecheck_test_outputs.sh")
}
}
// run via e.g.: ./gradlew checkExpectedOutputCompilesFor -PtestName="onefilesimple"
tasks.register("checkExpectedOutputCompilesFor", Exec) {
if (project.hasProperty("testName")) {
workingDir("src/test/resources")
if (System.getProperty("os.name").toLowerCase().startsWith("windows")) {
// Avoid("..") is not a command error
def scriptPath = file("typecheck_one_test.bat").absolutePath
commandLine("cmd", "/c", scriptPath, project.property("testName"))
} else {
commandLine("sh", "../../../typecheck_one_test.sh", project.property("testName"))
}
}
}
tasks.compileJava {
// uncomment for testing
// options.errorprone.enabled = false
options.errorprone.disable(
// JavaParser's visitor design requires us to regularly violate this rule
"VoidUsed",
// Specimin should compile with Java 11, but this suggestion assumes Java 17
"PatternMatchingInstanceof")
}
tasks.compileTestJava {
options.errorprone.enabled = false
}
checkerFramework {
// uncomment for testing
// skipCheckerFramework = true
checkers = [
"org.checkerframework.checker.nullness.NullnessChecker",
"org.checkerframework.checker.resourceleak.ResourceLeakChecker",
"org.checkerframework.checker.interning.InterningChecker",
"org.checkerframework.checker.signature.SignatureChecker"
]
excludeTests = true
extraJavacArgs = [
"-Astubs=${projectDir}/JavaParser.astub"
]
}
spotless {
// optional: limit format enforcement to just the files changed by this feature branch
ratchetFrom("origin/main")
format "misc", {
// define the files to apply `misc` to
target("*.gradle", "*.md", ".gitignore")
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}
java {
googleJavaFormat().reflowLongStrings()
formatAnnotations()
}
}
compileJava {
options.compilerArgs += ["-Werror"]
}
jar {
manifest {
attributes "Main-Class": "org.checkerframework.specimin.SpeciminRunner"
}
duplicatesStrategy = "exclude"
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}
compileJava.dependsOn("spotlessApply")
check.dependsOn(requireJavadoc)
java {
withJavadocJar()
withSourcesJar()
}
// Run `./gradlew publishToMavenLocal` to publish Specimin to your local Maven repository.
publishing {
publications {
maven(MavenPublication) {
groupId = "edu.njit.jerse"
artifactId = "specimin"
version = "0.1"
from(components.java)
}
}
}
javadoc {
if(JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption("html5", true)
}
}
tasks.withType(Test).configureEach {
// Creates half as many forks as there are CPU cores.
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}
test {
testLogging {
showStandardStreams = true
}
}
// Avoids "symbol not found" errors in builds immediately after cleaning.
// Not 100% sure why. One theory: test data would otherwise be treated as
// code by Gradle?
sourceSets {
test {
java.srcDirs = ["src/main/java/", "src/test/java/"]
}
}