forked from plume-lib/require-javadoc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
151 lines (130 loc) · 4.68 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
plugins {
id 'java'
id 'application'
// To create a fat jar build/libs/require-javadoc-all.jar, run: ./gradlew shadowJar
id 'com.github.johnrengelman.shadow' version '7.1.0'
// Formatting is disabled due to poor handling of type annotations; wait until
// this issue is fixed: https://github.com/google/google-java-format/issues/5
// // Code formatting with Google Java Format; defines targets "goJF" and "verJF".
// id 'com.github.sherter.google-java-format' version '0.7.1'
// Error Prone linter
id("net.ltgt.errorprone") version "2.0.2"
// Checker Framework pluggable type-checking
id 'org.checkerframework' version '0.6.4'
}
repositories {
mavenCentral()
}
dependencies {
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
implementation 'org.plumelib:options:1.0.5'
} else {
implementation 'org.plumelib:options:2.0.0'
}
implementation group: 'com.github.javaparser', name: 'javaparser-core', version: '3.23.1'
}
// To upload to Maven Central, see instructions in the file.
apply from: "${buildscript.sourceFile.parent}/gradle/mavencentral.gradle"
sourceCompatibility = 1.8
targetCompatibility = 1.8
application {
mainClass = 'org.plumelib.javadoc.RequireJavadoc'
}
/// Error Prone linter
dependencies {
errorprone("com.google.errorprone:error_prone_core:2.10.0")
// JDK 8 support for Error Prone:
errorproneJavac("com.google.errorprone:javac:9+181-r4173-1")
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << "-Xlint:all,-processing" << "-Werror"
options.errorprone {
// disable("ReferenceEquality") // Use Interning Checker instead.
// disable("StringSplitter") // obscure case isn't likely
// disable("AnnotateFormatMethod") // Error Prone doesn't know about Checker Framework @FormatMethod
// disable("UseCorrectAssertInTests") // Java's `assert` statument is so much more readable
}
}
/// Checker Framework pluggable type-checking
apply plugin: 'org.checkerframework'
checkerFramework {
checkers = [
'org.checkerframework.checker.formatter.FormatterChecker',
'org.checkerframework.checker.index.IndexChecker',
'org.checkerframework.checker.interning.InterningChecker',
'org.checkerframework.checker.lock.LockChecker',
'org.checkerframework.checker.nullness.NullnessChecker',
'org.checkerframework.checker.regex.RegexChecker',
'org.checkerframework.checker.signature.SignatureChecker'
]
extraJavacArgs = [
'-Werror',
'-AcheckPurityAnnotations',
'-ArequirePrefixInWarningSuppressions',
'-AwarnUnneededSuppressions',
]
}
// To use a locally-built Checker Framework, run gradle with "-PcfLocal".
if (project.hasProperty("cfLocal")) {
def cfHome = String.valueOf(System.getenv("CHECKERFRAMEWORK"))
dependencies {
compileOnly files(cfHome + "/checker/dist/checker-qual.jar")
testCompileOnly files(cfHome + "/checker/dist/checker-qual.jar")
checkerFramework files(cfHome + "/checker/dist/checker.jar")
}
}
/// Javadoc
// Turn Javadoc warnings into errors.
javadoc {
options.addStringOption('Xwerror', '-Xdoclint:all')
options.addStringOption('private', '-quiet')
if (JavaVersion.current().compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
options.addStringOption("-release", "8");
}
doLast {
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
ant.replaceregexp(match:"@import url\\('resources/fonts/dejavu.css'\\);\\s*", replace:'',
flags:'g', byline:true) {
fileset(dir: destinationDir)
}
}
}
}
check.dependsOn javadoc
task javadocWeb(type: Javadoc) {
description "Upload API documentation to website."
source = sourceSets.main.allJava
destinationDir = file("/cse/web/research/plumelib/${project.name}/api")
classpath = project.sourceSets.main.compileClasspath
if (JavaVersion.current().compareTo(org.gradle.api.JavaVersion.VERSION_1_9) >= 0) {
options.addStringOption("-release", "8");
}
doLast {
if (JavaVersion.current() == JavaVersion.VERSION_1_8) {
ant.replaceregexp(match:"@import url\\('resources/fonts/dejavu.css'\\);\\s*", replace:'',
flags:'g', byline:true) {
fileset(dir: destinationDir)
}
}
}
}
// Run require-javadoc on itself.
configurations {
requireJavadoc
}
dependencies {
requireJavadoc "org.plumelib:require-javadoc:1.0.2"
}
task requireJavadoc(type: JavaExec) {
description = 'Ensures that Javadoc documentation exists.'
mainClass = "org.plumelib.javadoc.RequireJavadoc"
classpath = configurations.requireJavadoc
args "src/main/java"
}
check.dependsOn requireJavadoc
/// Emacs support
/* Make Emacs TAGS table */
task tags(type: Exec) {
description "Run etags to create an Emacs TAGS table"
commandLine "bash", "-c", "find src/ -name '*.java' | sort | xargs etags"
}