-
Notifications
You must be signed in to change notification settings - Fork 119
/
build.gradle
372 lines (312 loc) · 14 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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
/*
* Copyright (c) 2021, Peter Abeles. All Rights Reserved.
*
* This file is part of Efficient Java Matrix Library (EJML).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import net.ltgt.gradle.errorprone.CheckSeverity
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
plugins {
id "com.peterabeles.gversion" version "1.10" apply false
id "net.ltgt.errorprone" version "2.0.2" apply false
id "com.diffplug.spotless" version "6.9.1" apply false
}
allprojects {
apply plugin: 'eclipse'
apply plugin: 'com.peterabeles.gversion'
group = 'org.ejml'
version = '0.43.1'
project.ext.commons_io_version = '2.11.0'
project.ext.lombok_version = '1.18.24'
project.ext.jabel_version = '1.0.0'
project.ext.guava_version = '31.1-jre'
project.ext.junit_version = '5.9.1'
project.ext.errorprone_version = '2.11.0'
project.ext.nullaway_version = '0.9.5'
project.ext.auto64to32_version = '3.2.0'
project.ext.jmh_version = '1.36'
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'
apply plugin: 'com.diffplug.spotless'
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 11 byte code but Java 17 syntax
tasks.withType(JavaCompile).configureEach {
sourceCompatibility = 17
options.release = 11
}
// Enable incremental compile. Should make single file changes faster
tasks.withType(JavaCompile) { options.incremental = true }
// Fail on jar conflict
configurations.all { resolutionStrategy { failOnVersionConflict() } }
// 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
// To make ErrorProne and Kotlin plugins happy
configurations.all {
resolutionStrategy {
force "org.jetbrains:annotations:$project.jetnull_version"
force "com.google.guava:guava:${guava_version}"
force "com.google.errorprone:error_prone_annotations:$errorprone_version"
force "com.google.code.findbugs:jsr305:$project.jsr305_version"
force 'org.checkerframework:checker-qual:2.10.0'
}
}
test {
useJUnitPlatform()
reports.html.enabled = false
testLogging.showStandardStreams = true // Print stdout making debugging easier
testLogging.exceptionFormat TestExceptionFormat.FULL
testLogging.showCauses true
testLogging.showExceptions true
testLogging.showStackTraces true
}
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' }
}
generate { java { srcDir 'generate' } }
benchmarks {
java { srcDir 'benchmarks/src' }
resources { srcDir 'benchmarks/resources' }
}
test {
java { srcDir 'test' }
resources { srcDir 'resources/test' }
}
}
dependencies {
compileOnly 'us.hebi.matlab.mat:mfl-ejml:0.5.7'
compileOnly "org.projectlombok:lombok:${project.lombok_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:${junit_version}")
testImplementation("org.junit.jupiter:junit-jupiter-params:${junit_version}")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${junit_version}")
generateImplementation project(':main:autocode')
annotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:$jabel_version")
testAnnotationProcessor("com.github.bsideup.jabel:jabel-javac-plugin:$jabel_version")
annotationProcessor "org.projectlombok:lombok:${lombok_version}" // @Getter @Setter
errorprone("com.google.errorprone:error_prone_core:$errorprone_version")
benchmarksImplementation project.sourceSets.main.runtimeClasspath
benchmarksImplementation project.sourceSets.main.compileClasspath
benchmarksImplementation("org.openjdk.jmh:jmh-core:$jmh_version")
benchmarksAnnotationProcessor("org.openjdk.jmh:jmh-generator-annprocess:$jmh_version")
// even if it's not used you still need to include the dependency
annotationProcessor "com.uber.nullaway:nullaway:${project.nullaway_version}"
testAnnotationProcessor "com.uber.nullaway:nullaway:${project.nullaway_version}"
benchmarksAnnotationProcessor "com.uber.nullaway:nullaway:${project.nullaway_version}"
generateAnnotationProcessor "com.uber.nullaway:nullaway:${project.nullaway_version}"
}
javadoc {
configure(options) {
links = ['https://docs.oracle.com/en/java/javase/11/docs/api/']
failOnError = false
enabled = !project.version.contains("SNAPSHOT") // disable to stop it from spamming stdout
}
}
// InconsistentCapitalization is disabled because in Math capital letters are often used for matrices and lower case
// for vectors or scalars. Perhaps a more verbose name should be used but it's disabled for now to reduce build spam
tasks.withType(JavaCompile).configureEach {
options.errorprone.enabled = false
if (path.contains("Benchmarks") || path.contains("examples") || path.contains("regression"))
return
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")
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", "org.ejml")
}
}
// Skip these codeless directories when publishing jars locally or to a remote destination
if (['main', 'examples', 'autocode', 'regression'].contains(name)) {
project.jar.enabled = false
project.tasks.publish.enabled = false
}
spotless {
ratchetFrom 'origin/SNAPSHOT'
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '*.md', '.gitignore'
// define the steps to apply to those files
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
}
java {
// There is no good way to ignore auto generated code since you can't check to see if it's in git or not
// there is no simple regex pattern. To apply spotless first remove all auto generated code.
target('**/ejml-core/src/org/ejml/**/*.java',
'**/ejml-ddense/src/org/ejml/**/*.java',
'**/ejml-dsparse/src/org/ejml/**/*.java',
'**/ejml-kotlin/src/org/ejml/**/*.java',
'**/ejml-simple/src/org/ejml/**/*.java',
'**/ejml-zdense/src/**/*.java')
toggleOffOn('formatter:off', 'formatter:on')
removeUnusedImports()
endWithNewline()
licenseHeaderFile "${project.rootDir}/docs/copyright.txt", 'package '
}
}
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 = 'EJML'
description = 'A fast and easy to use dense and sparse matrix linear algebra library written in Java.'
url = 'http://ejml.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 = '[email protected]'
}
}
scm {
connection = 'scm:git:git://github.com/lessthanoptimal/ejml.git'
developerConnection = 'scm:git:git://github.com/lessthanoptimal/ejml.git'
url = 'https://github.com/lessthanoptimal/ejml'
}
}
}
}
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.ossrhPassword != "dummy") {
signing { sign publishing.publications.mavenJava }
}
}
def allModules = [
':main:ejml-core',
':main:ejml-cdense',
':main:ejml-ddense',
':main:ejml-dsparse',
':main:ejml-dsparse',
':main:ejml-fdense',
':main:ejml-zdense',
':main:ejml-simple',
':main:ejml-experimental',
]
// Creates a directory with all the compiled jars
task createLibraryDirectory(dependsOn: allModules.collect { it + ":jar" } + allModules.collect { it + ":sourcesJar" }) {
doLast {
// Create lists of .class jars and source jars
ext.listJars = files(allModules.collect { project(it).tasks.jar.archivePath })
ext.listSource = files(allModules.collect { project(it).tasks.sourcesJar.archivePath })
file('libraries').deleteDir()
file('libraries').mkdir()
copy {
from ext.listJars
from ext.listSource
into 'libraries'
}
}
}
def javadocProjects = [
':main:ejml-core',
':main:ejml-ddense',
':main:ejml-dsparse',
':main:ejml-fdense',
':main:ejml-fsparse',
':main:ejml-zdense',
':main:ejml-cdense',
':main:ejml-simple'
]
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') }
// source = javadocProjects.collect { project(it).sourceSets.main.allJava }
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 = "Efficient Java Matrix Library (EJML) v$project.version"
links = ['http://docs.oracle.com/javase/8/docs/api/']
bottom = file('docs/bottom.txt').text
}
}
task oneJarBin(type: Jar, dependsOn: javadocProjects.collect { it + ":compileJava" }) {
archiveFile.set(file("ejml-v${project.version}.jar"))
from files(javadocProjects.collect { project(it).sourceSets.main.output.classesDirs }) {
exclude 'META-INF/*.RSA', 'META-INF/*.SF', 'META-INF/*.DSA'
}
}
wrapper {
distributionType = Wrapper.DistributionType.BIN
gradleVersion = '7.3.3'
}