File: build.gradle

package info (click to toggle)
georegression 0.24%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 2,248 kB
  • sloc: java: 23,565; makefile: 174; python: 45
file content (302 lines) | stat: -rw-r--r-- 11,018 bytes parent folder | download
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
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.1" apply false
}

allprojects {
    apply plugin: 'idea'
    apply plugin: 'eclipse'
    apply plugin: 'com.peterabeles.gversion'

    group = 'org.georegression'
    version = '0.24'
}

project.ext.set("errorprone_version", '2.7.1')

gversion {
    srcDir       = "main/src"
    classPackage = "georegression"
    className    = "GeoRegressionVersion"
    annotate     = true
}

subprojects {
    apply plugin: 'java-library'
    apply plugin: 'maven-publish'
    apply plugin: 'signing'
    apply plugin: 'net.ltgt.errorprone'

    java {
        withJavadocJar()
        withSourcesJar()
        toolchain { languageVersion = JavaLanguageVersion.of(15) }
    }

    // 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 { options.release = 8 }

    // 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:20.0.0'
            force 'com.google.guava:guava:30.1-jre'
            force "com.google.errorprone:error_prone_annotations:$project.errorprone_version"
            force 'com.google.code.findbugs:jsr305:3.0.2'
            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 (group: 'org.ddogleg', name: 'ddogleg', version: '0.20')

        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' )
        testRuntimeOnly( 'org.junit.jupiter:junit-jupiter-engine:5.4.0' )

        // needed to use Java 11+ syntax with Java 1.8 byte code
        annotationProcessor('com.github.bsideup.jabel:jabel-javac-plugin:0.3.0')
        testAnnotationProcessor('com.github.bsideup.jabel:jabel-javac-plugin:0.3.0')

        errorprone("com.google.errorprone:error_prone_core:$project.errorprone_version")

        // 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"
    }

    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")
        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 = ['http://docs.oracle.com/javase/8/docs/api/',
                     'http://ejml.org/javadoc/',
                     'http://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.uploadArchives.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.compile })
        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 = [ 'http://docs.oracle.com/javase/8/docs/api/',
                  'http://ejml.org/javadoc/',
                  'http://ddogleg.org/javadoc/' ]
    }
}

task javadocWeb() {
    doFirst {
        alljavadoc.options.bottom = file('docs/bottom.txt').text
        alljavadoc.destinationDir = file("${buildDir}/docs/api-web")
    }
}
javadocWeb.finalizedBy(alljavadoc)

project(':georegression').compileJava.dependsOn(createVersionFile)

wrapper {
    distributionType = Wrapper.DistributionType.BIN
    gradleVersion = '6.8.3'
}