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
|
/*
* 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 "1.2.1" apply false
id "com.diffplug.spotless" version "5.6.1" apply false
}
allprojects {
apply plugin: 'eclipse'
apply plugin: 'com.peterabeles.gversion'
group = 'org.ejml'
version = '0.41'
}
subprojects {
apply plugin: 'java-library'
apply plugin: 'maven-publish'
apply plugin: 'signing'
apply plugin: 'net.ltgt.errorprone'
apply plugin: 'com.diffplug.spotless'
java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
tasks.withType(JavaCompile).all {
options.incremental = true // Should make single file changes faster
options.compilerArgs = ["--release", "8",] // Output byte code compatible with Java 8
}
// Fail on jar conflict
configurations.all { resolutionStrategy { failOnVersionConflict() } }
// Force the release build to fail if it depends on a SNAPSHOT
jar.dependsOn checkDependsOnSNAPSHOT
// Force uploadArchives to fail if trying to upload a stable release and git is dirty
uploadArchives.dependsOn failDirtyNotSnapshot
// To make ErrorProne and Kotlin plugins happy
configurations.all {
resolutionStrategy {
force 'org.jetbrains:annotations:20.0.0'
force 'com.google.guava:guava:30.1-jre'
force 'com.google.errorprone:error_prone_annotations:2.4.0'
force 'com.google.code.findbugs:jsr305:3.0.2'
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:1.18.10'
compileOnly 'org.jetbrains:annotations:20.0.0' // @Nullable
compileOnly 'javax.annotation:jsr250-api:1.0' // @Generated
testCompileOnly project.sourceSets.main.compileClasspath
testImplementation( 'org.junit.jupiter:junit-jupiter-api:5.4.0' )
testImplementation( 'org.junit.jupiter:junit-jupiter-params:5.4.0' )
testRuntimeOnly( 'org.junit.jupiter:junit-jupiter-engine:5.4.0' )
generateCompile project(':main:autocode')
// needed to use Java 11+ syntax with Java 1.8 byte code
annotationProcessor('com.github.bsideup.jabel:jabel-javac-plugin:0.2.0') {
exclude group: 'net.bytebuddy', module: 'byte-buddy'
exclude group: 'net.bytebuddy', module: 'byte-buddy-agent'
}
annotationProcessor 'org.projectlombok:lombok:1.18.10' // @Getter @Setter
annotationProcessor("net.bytebuddy:byte-buddy:1.10.10")
annotationProcessor("net.bytebuddy:byte-buddy-agent:1.10.10")
errorprone "com.google.errorprone:error_prone_core:2.5.1" // adds benchmarks/generated to sourceSet
errorproneJavac "com.google.errorprone:javac:9+181-r4173-1" // annoying...
benchmarksImplementation project.sourceSets.main.runtimeClasspath
benchmarksImplementation project.sourceSets.main.compileClasspath
['1.27'].each { String a->
benchmarksCompile('org.openjdk.jmh:jmh-core:'+a)
benchmarksAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:'+a
}
// even if it's not used you still need to include the dependency
annotationProcessor "com.uber.nullaway:nullaway:0.8.0"
testAnnotationProcessor "com.uber.nullaway:nullaway:0.8.0"
benchmarksAnnotationProcessor "com.uber.nullaway:nullaway:0.8.0"
generateAnnotationProcessor "com.uber.nullaway:nullaway:0.8.0"
}
javadoc {
configure(options) {
links = ['http://docs.oracle.com/javase/8/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','main:autocode','regression'].contains(name)) {
project.jar.enabled = false
project.uploadArchives.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 = 'peter.abeles@gmail.com'
}
}
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)
// 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 = '6.4.1'
}
|