-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.gradle
306 lines (255 loc) · 11.4 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins {
id "com.peterabeles.gversion" version "1.10.2" apply false
id "net.ltgt.errorprone" version "2.0.1" apply false
}
allprojects {
apply plugin: 'com.peterabeles.gversion'
group = 'org.georegression'
version = '0.27.4-SNAPSHOT'
}
project.ext.ddogleg_version = '0.23.4'
project.ext.errorprone_version = '2.11.0'
project.ext.nullaway_version = '0.9.5'
project.ext.lombok_version = '1.18.24'
project.ext.jabel_version = '1.0.0'
project.ext.junit_version = '5.8.2'
project.ext.guava_version = '31.1-jre'
project.ext.jetnull_version = '23.0.0'
project.ext.jsr250_version = '1.0'
project.ext.jsr305_version = '3.0.2'
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'net.ltgt.errorprone'
java {
withJavadocJar()
withSourcesJar()
toolchain { languageVersion = JavaLanguageVersion.of(17) }
}
// Prevents tons of errors if someone is using ASCII
tasks.withType(JavaCompile).configureEach { options.encoding = "UTF-8" }
// Creates Java 8 byte code
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = 17
options.release = 11
}
// Enable incremental compile. Should make single file changes faster
tasks.withType(JavaCompile) { options.incremental = true }
// To make ErrorProne and Kotlin plugins happy
configurations.configureEach {
resolutionStrategy {
force "org.jetbrains:annotations:$project.jetnull_version"
force "com.google.guava:guava:$project.guava_version"
force "com.google.errorprone:error_prone_annotations:$project.errorprone_version"
force "com.google.code.findbugs:jsr305:$project.jsr305_version"
force 'org.checkerframework:checker-qual:2.10.0'
}
}
// Fail on jar conflict
configurations.all { resolutionStrategy { failOnVersionConflict() } }
repositories {
mavenCentral()
mavenLocal()
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url = 'https://jitpack.io' } // Allows annotations past Java 8 to be used
}
sourceSets {
main {
java { srcDir 'src' }
resources { srcDir 'resources/src' }
}
test {
java {
srcDir 'test'
srcDir 'generate'
srcDir 'benchmark'
}
resources { srcDir 'resources/test' }
}
}
dependencies {
implementation "org.ddogleg:ddogleg:$project.ddogleg_version"
compileOnly "org.jetbrains:annotations:$project.jetnull_version" // @Nullable
compileOnly "javax.annotation:jsr250-api:$project.jsr250_version" // @Generated
testCompileOnly project.sourceSets.main.compileClasspath
testImplementation( "org.junit.jupiter:junit-jupiter-api:$project.junit_version" )
testRuntimeOnly( "org.junit.jupiter:junit-jupiter-engine:$project.junit_version" )
// needed to use Java 15+ syntax with Java 11 byte code
annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:${project.jabel_version}")
testAnnotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:${project.jabel_version}")
errorprone("com.google.errorprone:error_prone_core:$project.errorprone_version")
compileOnly "org.projectlombok:lombok:${project.lombok_version}"
annotationProcessor "org.projectlombok:lombok:${project.lombok_version}" // @Getter @Setter
// even if it's not used you still need to include the dependency
// NOTE: nullaway is disabled due to switch expression bug https://github.com/uber/NullAway/issues/289
annotationProcessor "com.uber.nullaway:nullaway:$project.nullaway_version"
testAnnotationProcessor "com.uber.nullaway:nullaway:$project.nullaway_version"
}
tasks.withType(JavaCompile).configureEach {
options.errorprone.enabled = true
options.errorprone.disableWarningsInGeneratedCode = true
options.errorprone.disable("TypeParameterUnusedInFormals","StringSplitter","InconsistentCapitalization",
"HidingField", // this is sometimes done when the specific type is known by child. Clean up later.
"ClassNewInstance", // yes it's deprecated, but new version is more verbose with ignored errors
"FloatingPointLiteralPrecision", // too many false positives in test code
"MissingSummary","UnescapedEntity","EmptyBlockTag", "SameNameButDifferent")
options.errorprone.error("MissingOverride","MissingCasesInEnumSwitch","BadInstanceof",
"PublicConstructorForAbstractClass","EmptyCatch","NarrowingCompoundAssignment","JdkObsolete")
if( name.startsWith("compileTest") ) {
options.errorprone.disable("ReferenceEquality","IntLongMath","ClassCanBeStatic")
}
options.errorprone {
check("NullAway", CheckSeverity.ERROR)
option("NullAway:TreatGeneratedAsUnannotated", true)
option("NullAway:AnnotatedPackages", "georegression")
}
}
test {
useJUnitPlatform()
reports.html.enabled = false
// Make the error logging verbose to make debugging on CI easier
testLogging.showStandardStreams = true
testLogging.exceptionFormat TestExceptionFormat.FULL
testLogging.showCauses true
testLogging.showExceptions true
testLogging.showStackTraces true
}
javadoc {
configure(options) {
links = ['https://docs.oracle.com/en/java/javase/11/docs/api/',
'https://ejml.org/javadoc/',
'https://ddogleg.org/javadoc/']
failOnError = false
enabled = !project.version.contains("SNAPSHOT") // disable to stop it from spamming stdout
}
// https://github.com/gradle/gradle/issues/11182 Error introduced in JDK 11
if (JavaVersion.current().compareTo(JavaVersion.VERSION_1_9) >= 0) {
options.addStringOption("-release", "8")
}
if (JavaVersion.current().isJava9Compatible()) {
options.addBooleanOption('html5', true)
}
}
// Force the release build to fail if it depends on a SNAPSHOT
project.jar.dependsOn project.checkDependsOnSNAPSHOT
// Force publish to fail if trying to upload a stable release and git is dirty
project.publish.dependsOn failDirtyNotSnapshot
// Skip these codeless directories when publishing jars locally or to a remote destination
if (['examples','autocode'].contains(name)) {
project.jar.enabled = false
project.tasks.publish.enabled = false
}
if (!project.tasks.publish.enabled)
return
// if Maven central isn't setup in ~/.gradle/gradle.properties fill in these variables to make it happy
if( !project.hasProperty('ossrhUsername') ) {
ext.ossrhUsername = "dummy"
ext.ossrhPassword = "dummy"
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
pom {
name = 'GeoRegression'
description = 'GeoRegression is a free Java based geometry library for scientific computing in fields such as robotics and computer vision with a focus on 2D/3D space.'
url = 'http://georegression.org'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'pabeles'
name = 'Peter Abeles'
email = 'peter.abeles@gmail.com'
}
}
scm {
connection = 'scm:git:git://github.com/lessthanoptimal/georegression.git'
developerConnection = 'scm:git:git://github.com/lessthanoptimal/georegression.git'
url = 'https://github.com/lessthanoptimal/GeoRegression'
}
}
}
}
repositories {
maven {
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials {
username ossrhUsername
password ossrhPassword
}
}
}
}
if (ext.ossrhUsername != "dummy") {
signing { sign publishing.publications.mavenJava }
}
}
// Creates a directory with all the compiled jars and the dependencies
def mainProjects = [':georegression',":experimental"]
task createLibraryDirectory( dependsOn: mainProjects.collect {[ it+':jar',it+':sourcesJar']}.flatten() ) {
doLast {
ext.listExternal = files(mainProjects.collect { project(it).configurations.runtimeClasspath })
ext.listInternal = files(mainProjects.collect { project(it).tasks.jar.archivePath })
ext.listSource = files(mainProjects.collect { project(it).tasks.sourcesJar.archivePath })
ext.listExternal = ext.listExternal - ext.listInternal
file('libraries').deleteDir()
file('libraries').mkdir()
copy {
from ext.listExternal
into 'libraries'
}
copy {
from ext.listInternal
from ext.listSource
into 'libraries'
rename { String fileName ->
"GeoRegression-" + fileName
}
}
}
}
def javadocProjects = [
':georegression',
]
task alljavadoc(type: Javadoc) {
// only include source code in src directory to avoid including 3rd party code which some projects do as a hack
source = javadocProjects.collect { project(it).fileTree('src').include('**/*.java') }
classpath = files(javadocProjects.collect { project(it).sourceSets.main.compileClasspath })
destinationDir = file("${buildDir}/docs/javadoc")
// Hack for Java 8u121 and beyond. Comment out if running an earlier version of Java
options.addBooleanOption("-allow-script-in-comments", true)
// Flag is no longer around in later versions of Java but required before
if (JavaVersion.current().ordinal() < JavaVersion.VERSION_13.ordinal()) {
options.addBooleanOption("-no-module-directories", true)
}
// Add a list of uses of a class to javadoc
options.use = true
configure(options) {
failOnError = false
docTitle = "GeoRegression v$project.version"
links = [ 'https://docs.oracle.com/en/java/javase/11/docs/api/',
'https://ejml.org/javadoc/',
'https://ddogleg.org/javadoc/' ]
}
}
task javadocWeb() {
doFirst {
alljavadoc.options.bottom = file('docs/bottom.txt').text
alljavadoc.destinationDir = file("${buildDir}/docs/api-web")
}
}
javadocWeb.finalizedBy(alljavadoc)
wrapper {
distributionType = Wrapper.DistributionType.BIN
gradleVersion = '7.6.4'
}