Newer
Older
buildscript {
repositories {
jcenter()
}
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.27.1"
classpath "com.github.spotbugs:spotbugs-gradle-plugin:3.0.0"
classpath "gradle.plugin.com.star-zero.gradle:githook:1.2.0"
}
}
apply from: "${projectDir}/gradle/git-hooks.gradle"
apply from: "${projectDir}/gradle/spotbugs.gradle"
apply from: "${projectDir}/gradle/spotless.gradle"
repositories {
jcenter()
}
dependencies {
api 'com.google.guava:guava:28.2-jre'
api 'com.google.code.gson:gson:2.8.6'
annotationProcessor platform("io.micronaut:micronaut-bom:1.3.2")
annotationProcessor "io.micronaut:micronaut-inject-java"
implementation platform("io.micronaut:micronaut-bom:1.3.2")
implementation "io.micronaut:micronaut-http-client"
implementation "io.micronaut:micronaut-inject"
testImplementation 'org.junit.jupiter:junit-jupiter:5.5.2'
testImplementation 'org.hamcrest:hamcrest-library:1.3'
gitTag = 'git describe --tags'.execute().text.replace('\n', '') ?: 'unknown'
gitLink = '<a href="https://code.usgs.gov/ghsc/nshmp/nshmp-lib">' + gitTag +'</a>'
propsPath = '/resources/main/app.properties'
docTitle = projectName + ': ' + gitLink
}
test {
reports {
junitXml.enabled = true
html.enabled = true
}
includeTestsMatching "gov.usgs.earthquake.nshmp.EarthquakesTests"
includeTestsMatching "gov.usgs.earthquake.nshmp.FaultsTests"
includeTestsMatching "gov.usgs.earthquake.nshmp.MathsTests"
includeTestsMatching "gov.usgs.earthquake.nshmp.data.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.eq.fault.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.eq.model.LoaderTests"
includeTestsMatching "gov.usgs.earthquake.nshmp.eq.model.ModelConfigTests"
includeTestsMatching "gov.usgs.earthquake.nshmp.geo.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.gmm.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.internal.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.mfd.*"
includeTestsMatching "gov.usgs.earthquake.nshmp.tree.*"
// TODO: Remove when updated
excludeTestsMatching "gov.usgs.earthquake.nshmp.internal.NshmFaultSectionTests"
}
jacocoTestReport {
reports {
xml.enabled true
}
}
javadoc {
options.setUse(true)
options.author(true)
options.version(true)
options.windowTitle(projectName)
options.docTitle(docTitle)
options.encoding('UTF-8')
options.docEncoding('UTF-8')
options.charSet('UTF-8')
options.addStringOption('Xdoclint:none', '-quiet')
options.links(
'https://docs.oracle.com/javase/8/docs/api/',
'https://google.github.io/guava/releases/26.0-jre/api/docs/')
}
/*
* Enhance the jar task to build a fat jar if running the build
* directly and add application version to a properties file.
* Note that 'git describe' only works when running gradle from
* the command line.
*/
jar {
doFirst {
/* possible fat jar */
if (rootProject.name == projectName) {
from {
configurations.compileClasspath.collect {
it.isDirectory() ? it : zipTree(it).matching {
exclude { it.path.contains('META-INF') }
}
/* record app version */
def props = new Properties()
def propsFile = new File(project.buildDir.toString() + propsPath)
propsFile.getParentFile().mkdirs()
propsFile.createNewFile()
props.setProperty('app.version', gitTag)
props.store(propsFile.newWriter(), null)
}
}
/* Add HTML reports to SpotBugs */
tasks.withType(com.github.spotbugs.SpotBugsTask) {
reports {
xml.enabled = false
html.enabled = true
}
}