Skip to content
Snippets Groups Projects
build.gradle 2.79 KiB
Newer Older
  • Learn to ignore specific revisions
  •  * In order to build and run services locally,
     * one needs to include the following directorie(s) in the root project (they
    
     * are ignored by git):
     *
    
     *    models/
     *       ak/
     *          2007/
     *       wus/
     *          2008/
     *          2014/
     *          2014b/
     *          2018/
     *       ceus/
     *          2008/
     *          2014/
     *          2018/
    
     *
     * ...with each 'year' directory being an alias to the corresponding
    
     * git repository. One only needs to include the model they will run in the services.
     *
     * Then build the JAR file: ./gradlew assemble
     *
     * One can then specify the model to run in the services:
    
     *    java -jar build/libs/nshmp-haz.jar --models=/path/to/models
    
     *
     * Where <MODEL> is one of the model enums in nshmp.www.Model
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
    
    
    plugins {
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      id "application"
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
      id "com.diffplug.spotless" version "${spotlessVersion}"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      id "com.github.johnrengelman.shadow" version "${shadowVersion}"
    
      id "com.github.node-gradle.node" version "${nodeVersion}"
      id "com.github.spotbugs" version "${spotbugsVersion}"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      id "com.star-zero.gradle.githook" version "${githooksVersion}"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      id "eclipse-wtp"
    
      id "io.micronaut.application" version "${mnPluginVersion}"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      id "jacoco"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      id "maven-publish"
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
    
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    configurations {
      nshmp
    }
    
    apply from: "${projectDir}/gradle/dependencies.gradle"
    
    apply from: "${projectDir}/gradle/ext.gradle"
    apply from: "${projectDir}/gradle/jar.gradle"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    apply from: "${projectDir}/gradle/repositories.gradle"
    
    sourceCompatibility = JavaVersion.VERSION_11
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    compileJava.options.encoding = "UTF-8"
    
    mainClassName = "gov.usgs.earthquake.nshmp.www.Application"
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
    jacoco {
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      toolVersion = "0.8.4"
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
    test {
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      useJUnitPlatform()
    
      
      filter {
        excludeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTestsLarge"
      }
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
    }
    
    jacocoTestReport {
      reports {
        xml.enabled true
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
        html.enabled true
    
        classDirectories.from(files(classDirectories.files.collect {
    
              dir: it,
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
              exclude: ["**/etc/**"])
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
    check.dependsOn jacocoTestReport
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    tasks.withType(JavaCompile) {
      options.encoding = "UTF-8"
      options.compilerArgs.add("-parameters")
    }
    
    tasks.withType(JavaExec) {
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
      jvmArgs('-noverify', '-Xms2g', '-Xmx8g', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
    
    /* Add HTML reports to SpotBugs */
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
    
      reports {
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
        html {
          enabled true
          stylesheet = 'fancy-hist.xsl'
        }
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    
    task libsClean(type: Delete) {
      delete libsDir
    }
    clean.dependsOn libsClean
    
    gradle.afterProject {
      copy {
        from {
          configurations.nshmp.collect { zipTree(it) }
        }
        into nshmpLib
      }
      apply from: "${nshmpLibGradleDir}/git-hooks.gradle"
    
      apply from: "${nshmpLibGradleDir}/node.gradle"
    
      apply from: "${nshmpLibGradleDir}/spotbugs.gradle"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      apply from: "${nshmpLibGradleDir}/spotless.gradle"
    }