Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
179 lines (157 loc) · 5.72 KB
/
Copy pathbuild.gradle
File metadata and controls
179 lines (157 loc) · 5.72 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
plugins {
id 'com.palantir.git-version' version '0.12.3'
id 'java-library'
id 'maven-publish'
id 'org.jreleaser' version '1.20.0'
}
group = 'edu.uiowa.cs.clc'
version = gitVersion()
ext.isReleaseVersion = version.matches("[0-9]+.[0-9]+.[0-9]+")
repositories {
mavenCentral()
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.6'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.6.2'
}
test {
useJUnitPlatform()
}
java {
withJavadocJar()
withSourcesJar()
}
tasks.withType(Javadoc).configureEach {
options.addBooleanOption('Xdoclint:all', true)
failOnError = true
}
// The javadoc task above runs doclint, but Gradle always passes -quiet, which
// hides warning-level diagnostics such as "no comment", and it does not fail on
// them. This task runs doclint separately and fails `check` if anything is
// reported.
//
// Only newer JDKs report missing documentation: JDK 11 reports none, JDK 25
// reports it, and the documentation here was verified against JDK 25. Rather
// than hard-code a version, the task probes the javadoc it is about to use and
// skips when that javadoc cannot report a missing comment, so building on an
// older JDK (CI uses Java 8) neither fails nor gives false assurance.
def javadocTool = javaToolchains.javadocToolFor(java.toolchain)
def doclintCheck = tasks.register('doclintCheck') {
description = 'Runs javadoc doclint over the main sources and fails on any warning.'
group = 'verification'
dependsOn tasks.named('classes')
def sources = sourceSets.main.allJava
def classpath = sourceSets.main.compileClasspath
def workDir = layout.buildDirectory.dir('tmp/doclint')
def tool = javadocTool
inputs.files(sources)
inputs.files(classpath)
outputs.dir(workDir)
doLast {
def dir = workDir.get().asFile
dir.deleteDir()
dir.mkdirs()
// Resolve javadoc through the toolchain: on Java 8, java.home points at the
// JRE, which has no bin/javadoc.
def javadoc = tool.get().executablePath.asFile.absolutePath
// The in-process javadoc ToolProvider ignores -Xdoclint, so fork the real
// executable and read its diagnostics.
def runJavadoc = { List<String> extraArgs ->
def process = new ProcessBuilder([javadoc] + extraArgs)
.redirectErrorStream(true).start()
def text = process.inputStream.text
[output: text, exitCode: process.waitFor(),
problems: text.readLines().findAll { it =~ /: (warning|error): / }]
}
def flags = ['-Xdoclint:all', '-Xmaxwarns', '100000']
// Probe: a public method with no comment, run with the same flags as the
// real check. If this javadoc does not flag it -- because its doclint does
// not report missing documentation, or because it rejects one of the flags
// -- the real run would prove nothing, so skip rather than give false
// assurance or fail for an environmental reason.
def probeDir = new File(dir, 'probe')
probeDir.mkdirs()
def probeSource = new File(probeDir, 'DoclintProbe.java')
probeSource.text = 'public class DoclintProbe { public void undocumented() {} }\n'
def probe = runJavadoc(flags + ['-d', new File(probeDir, 'out').absolutePath,
probeSource.absolutePath])
if (probe.problems.isEmpty()) {
logger.lifecycle('doclintCheck: skipped, ' + javadoc +
' does not report missing documentation (needs a newer JDK).')
return
}
def argFile = new File(dir, 'sources.txt')
argFile.text = sources.files.collect { it.absolutePath }.join('\n')
def result = runJavadoc(flags + ['-classpath', classpath.asPath,
'-d', new File(dir, 'out').absolutePath,
'@' + argFile.absolutePath])
if (result.exitCode != 0 || !result.problems.isEmpty()) {
result.problems.each { logger.error(it) }
throw new GradleException(
"javadoc doclint reported ${result.problems.size()} problem(s); see the messages above.")
}
}
}
tasks.named('check') {
dependsOn doclintCheck
}
publishing {
publications {
maven(MavenPublication) {
from components.java
pom {
name = 'Kind 2 Java API'
description = 'An API for constructing Lustre programs, running Kind 2, and showing results/suggestions.'
url = 'https://github.com/kind2-mc/kind2-java-api'
licenses {
license {
name = 'BSD 3-Clause License'
url = 'https://github.com/kind2-mc/kind2-java-api/blob/master/LICENSE'
}
}
developers {
developer {
id = 'daniel-larraz'
name = 'Daniel Larraz'
email = 'daniel-larraz@uiowa.edu'
}
}
scm {
connection = 'scm:git:https://github.com/kind2-mc/kind2-java-api.git'
developerConnection = 'scm:git:ssh:github.com/kind2-mc/kind2-java-api.git'
url = 'https://github.com/kind2-mc/kind2-java-api'
}
}
}
}
repositories {
maven {
url = layout.buildDirectory.dir('staging-deploy')
}
}
}
jreleaser {
signing {
active = 'ALWAYS'
armored = true
}
deploy {
maven {
mavenCentral {
sonatype {
active = 'ALWAYS'
url = 'https://central.sonatype.com/api/v1/publisher'
stagingRepository('build/staging-deploy')
}
}
github {
packages {
active = 'ALWAYS'
url = 'https://maven.pkg.github.com/kind2-mc/kind2-java-api'
stagingRepository('build/staging-deploy')
}
}
}
}
}