-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
192 lines (156 loc) · 5.63 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
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
/*
* RiceChecks
* Copyright (c) 2019, Dan S. Wallach, Rice University
* Available subject to the Apache 2.0 License
*/
buildscript {
ext.gradeProject = "Sorting"
ext.gradePackage = "edu.rice.sort"
ext.gradeConfig = "config/grade.yml"
repositories {
maven { url "https://maven-central.storage.googleapis.com" }
jcenter()
mavenCentral()
}
}
plugins {
id 'java'
id 'checkstyle'
id 'jacoco'
id "net.ltgt.errorprone" version "0.7.1" // JDK9+
id 'com.github.sherter.google-java-format' version '0.8'
}
group 'edu.rice'
version '1.0'
checkstyle {
toolVersion = '8.17'
configDir = project.file("config/checkstyle")
reportsDir = project.file("build/reports/checkstyle")
}
allprojects {
// Makes the "javadoc" action run without a ton of warnings.
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
tasks.withType(JavaCompile) {
options.fork = true
options.incremental = true
options.encoding = "UTF-8"
options.compilerArgs << "-Xlint:all" << "-Xlint:-serial" << "-Xlint:-processing" << "-Xlint:-deprecation"
// ErrorProne's "unused" warnings seems to trigger far too often, so we're suppressing them.
options.errorprone.errorproneArgs << "-Xep:UnusedVariable:OFF" << "-Xep:UnusedMethod:OFF"
sourceCompatibility = '11'
targetCompatibility = '11'
}
}
////////////////////////////////////////////////////////////////////////////////
// This section configures JaCoCo (Java Code Coverage), JUnit (unit tests), GoogleJavaFormat,
// and the autograder.
jacoco {
toolVersion = "0.8.3"
}
jacocoTestReport {
reports {
xml.enabled = true
csv.enabled = false
html.destination file("${buildDir}/reports/jacoco/")
}
}
// We need to capture the errors and warnings printed by the Java compiler.
// Everything else is already written into the build directory, but not this.
task initLogFile {
doLast {
file("$buildDir").mkdir()
file("$buildDir/logs").mkdir()
def gradleBuildLog = file("$buildDir/logs/compile.log")
gradleBuildLog.write("") // empty write forces file to exist with size 0
def fileLogger = new StandardOutputListener() {
void onOutput(CharSequence output) {
gradleBuildLog << output
}
}
tasks.withType(JavaCompile) {
logger.info("compilation logging for $it")
logging.addStandardOutputListener(fileLogger)
logging.addStandardErrorListener(fileLogger)
}
}
}
compileJava.dependsOn initLogFile
test {
useJUnitPlatform()
outputs.upToDateWhen { false }
minHeapSize = "512m"
maxHeapSize = "2048m"
jvmArgs = ["-Xss128m"]
ignoreFailures true
}
googleJavaFormat {
toolVersion = '1.7'
}
import com.github.sherter.googlejavaformatgradleplugin.VerifyGoogleJavaFormat
task autograderVerifyGoogleJavaFormat(type: VerifyGoogleJavaFormat) {
source 'src/main'
source 'src/test'
include '**/*.java'
ignoreFailures true
}
configurations {
ricechecks
}
task autograder {
dependsOn 'classes', 'jacocoTestCoverageVerification', 'jacocoTestReport',
'autograderVerifyGoogleJavaFormat', 'checkstyleMain', 'checkstyleTest', 'test'
doLast {
// See: https://github.com/RiceComp215-Staff/RiceChecks/issues/5
gradle.buildFinished { ignoredResult ->
project.javaexec {
classpath = configurations.ricechecks
main = "edu.rice.autograder.AutoGraderKt"
args = [ "--project", gradeProject,
"--config", gradeConfig,
"grade" ]
}
}
}
}
task autograderDebugAnnotations (type: JavaExec) {
dependsOn 'classes'
classpath([configurations.ricechecks, sourceSets.main.runtimeClasspath, sourceSets.test.runtimeClasspath])
main = "edu.rice.autograder.AutoGraderKt"
args = [ "--package", gradePackage, "--project", gradeProject, "--log", "all", "debugAnnotations" ]
}
task autograderWriteConfig (type: JavaExec) {
dependsOn 'classes'
classpath([configurations.ricechecks, sourceSets.main.runtimeClasspath, sourceSets.test.runtimeClasspath])
main = "edu.rice.autograder.AutoGraderKt"
args = [ "--package", gradePackage, "--project", gradeProject, "--config", gradeConfig, "writeConfig" ]
}
////////////////////////////////////////////////////////////////////////////////
// This section specifies all the external libraries being used by your Java
// program and where to find them.
repositories {
mavenLocal()
maven { url "https://maven-central.storage.googleapis.com" }
mavenCentral()
}
dependencies {
// autograder annotations
implementation 'edu.rice.ricechecks:ricechecks-annotations:0.8.0'
// autograder tool
ricechecks 'edu.rice.ricechecks:ricechecks:0.8.0'
// fancy compiler warnings / lint
errorprone 'com.google.errorprone:error_prone_core:2.3.3'
// logging
implementation 'ch.qos.logback:logback-classic:1.2.3'
// annotations to help ErrorProne and IntelliJ find bugs
implementation 'org.jetbrains:annotations:15.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.google.code.findbugs:annotations:3.0.1'
implementation 'com.google.errorprone:error_prone_annotations:2.3.3'
// JUnit5 support
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.4.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.0'
// QuickTheories, for property-based testing
testImplementation 'org.quicktheories:quicktheories:0.25'
}