-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
175 lines (145 loc) · 5.04 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
/*
* RiceChecks
* Copyright (c) 2019, Dan S. Wallach, Rice University
* Available subject to the Apache 2.0 License
*/
buildscript {
ext.gradeProject = "RE"
ext.gradePackage = "edu.rice.regex"
ext.gradeConfig = "config/grade.yml"
repositories {
google()
mavenCentral()
jcenter()
}
}
plugins {
id 'java'
id 'checkstyle'
id 'jacoco'
// id "net.ltgt.errorprone" version "0.7.1" // JDK9+
// id 'net.ltgt.errorprone' version '0.0.14' // JDK8
id "net.ltgt.errorprone" version "3.0.1"
id 'com.github.sherter.google-java-format' version '0.8'
}
group 'edu.rice'
version '1.0'
checkstyle {
toolVersion('8.17')
}
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" << "-Xep:UnusedVariable:OFF" << "-Xep:UnusedMethod:OFF"
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
////////////////////////////////////////////////////////////////////////////////
// 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
}
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 = sourceSets.main.runtimeClasspath
main = "edu.rice.autograder.AutoGraderKt"
args = [ "--project", gradeProject,
"--config", gradeConfig,
"grade" ]
}
}
}
}
task autograderDebugAnnotations (type: JavaExec) {
classpath([sourceSets.main.runtimeClasspath, sourceSets.test.runtimeClasspath])
main = "edu.rice.autograder.AutoGraderKt"
args = [ "--package", gradePackage, "--project", gradeProject, "debugAnnotations" ]
}
task autograderWriteConfig (type: JavaExec) {
classpath([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()
google()
mavenCentral()
}
dependencies {
// this creates a dependency on the autograder subproject: see the README.md
// file for how to set up a standalone project
implementation project (':autograder')
// logging
implementation 'ch.qos.logback:logback-classic:1.2.9'
// 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.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.4.2'
}