Skip to content
Snippets Groups Projects
build.gradle 2.43 KiB
Newer Older
  • Learn to ignore specific revisions
  • plugins {
    
      id "com.diffplug.spotless"
      id "com.github.spotbugs"
      id "com.github.node-gradle.node"
      id "com.star-zero.gradle.githook"
    
      id "eclipse-wtp"
      id "jacoco"
      id "java-library"
    
      id "maven-publish"
    
    compileJava.options.encoding = "UTF-8"
    
    compileTestJava.options.encoding = "UTF-8"
    sourceCompatibility = JavaVersion.VERSION_11
    
    
    apply from: "${projectDir}/gradle/git-hooks.gradle"
    
    apply from: "${projectDir}/gradle/node.gradle"
    
    apply from: "${projectDir}/gradle/repositories.gradle"
    
    apply from: "${projectDir}/gradle/spotbugs.gradle"
    apply from: "${projectDir}/gradle/spotless.gradle"
    
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    dependencies {
    
      api "com.google.guava:guava:${guavaVersion}"
      api "com.google.code.gson:gson:${gsonVersion}"
    
      testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    }
    
    jacocoTestReport {
      reports {
        xml.enabled true
    
        html.enabled true
    
    check.dependsOn jacocoTestReport
    
    java {
      withJavadocJar()
      withSourcesJar()
    }
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    
    javadoc {
    
      def docTitle = "<a href=\"https://code.usgs.gov/ghsc/nshmp/nshmp-lib.git\">${project.name}</a>"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      options.setUse(true)
      options.author(true)
      options.version(true)
    
      options.windowTitle(project.name)
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      options.docTitle(docTitle)
    
      options.encoding("UTF-8")
      options.docEncoding("UTF-8")
      options.charSet("UTF-8")
    
      options.addBooleanOption("Xdoclint:none", true)
    
      options.addBooleanOption("-no-module-directories", true)
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
      options.overview = "src/main/resources/overview.html"
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
      options.links(
    
          "https://docs.oracle.com/en/java/javase/11/docs/api/",
          "https://google.github.io/guava/releases/26.0-jre/api/docs/")
      include "gov/usgs/earthquake/nshmp/**"
    
    Powers, Peter M.'s avatar
    Powers, Peter M. committed
      exclude "gov/usgs/earthquake/nshmp/internal/**"
    
    // temporary task to support local running of lib while developing
    // model parsing classes; TODO remove when parser is stable
    task fatJar(type: Jar) {
      from {
        configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
        configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
      }
      with jar
    }
    
    Clayton, Brandon Scott's avatar
    Clayton, Brandon Scott committed
    
    /* Add HTML reports to SpotBugs */
    tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
      reports {
        html {
          enabled true
    
          stylesheet = "fancy-hist.xsl"
    
    
    test {
      useJUnitPlatform()
    
      maxHeapSize = "1g"
    
      reports {
        junitXml.enabled = true
        html.enabled = true
      }
    
      filter {
        excludeTestsMatching "gov.usgs.earthquake.nshmp.model.NshmTestsLargeTmp"
        // e.g. excludeTestsMatching "gov.usgs.earthquake.nshmp.model.LoaderTests"
      }
    }