Skip to content
Snippets Groups Projects
Commit 687b4d8e authored by Clayton, Brandon Scott's avatar Clayton, Brandon Scott
Browse files

Add gradle files

parent 51615cf9
No related branches found
No related tags found
2 merge requests!86Production Release | nshmp-ws-static,!81Resolves - Gradle Build
......@@ -11,27 +11,17 @@ plugins {
id "maven-publish"
}
sourceCompatibility = JavaVersion.VERSION_11
compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"
mainClassName = "gov.usgs.earthquake.nshmp.netcdf.www.Application"
sourceCompatibility = JavaVersion.VERSION_11
configurations {
nshmp
}
ext {
libsDir = "libs"
nshmpLib = "${libsDir}/nshmp-lib-artifacts"
nshmpLibGradleDir = "${nshmpLib}/gradle"
spotbugsDir = "${nshmpLib}/gradle"
spotlessDir = "${nshmpLib}/src/main/resources"
swaggerDir = "swagger-files"
}
apply from: "${projectDir}/gradle/repositories.gradle"
apply from: "${projectDir}/gradle/dependencies.gradle"
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"
test {
useJUnitPlatform()
......@@ -62,6 +52,11 @@ tasks.withType(JavaExec) {
jvmArgs('-noverify', '-XX:TieredStopAtLevel=1', '-Dcom.sun.management.jmxremote')
}
task libsClean(type: Delete) {
delete "libs"
}
clean.dependsOn libsClean
/* SpotBugs */
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
reports {
......@@ -71,35 +66,3 @@ tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
}
}
}
/* Run UpdateSwagger */
task swagger(type: JavaExec) {
doFirst {
mkdir swaggerDir
}
classpath sourceSets.main.runtimeClasspath
main = "gov.usgs.earthquake.nshmp.netcdf.swagger.UpdateSwagger"
}
assemble.dependsOn swagger
task swaggerClean(type: Delete) {
delete swaggerDir
}
clean.dependsOn swaggerClean
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}/spotbugs.gradle"
apply from: "${nshmpLibGradleDir}/spotless.gradle"
}
apply plugin: "com.star-zero.gradle.githook"
/**
* Add Git hooks on pre commit and pre push.
*
* See https://github.com/STAR-ZERO/gradle-githook
*/
githook {
createHooksDirIfNotExist = true
hooks {
"pre-push" {
task = "markdownlint yamllint spotlessCheck spotbugsMain spotbugsTest"
}
}
}
<FindBugsFilter>
<!-- Caused by Java 11 generating a null check on try with resources. This
passed on Java 8 -->
<Match>
<Bug pattern="RCN_REDUNDANT_NULLCHECK_WOULD_HAVE_BEEN_A_NPE" />
</Match>
<!-- StringConverter.INSTANCE.convert(this) will never be null -->
<Match>
<Class name="gov.usgs.earthquake.nshmp.geo.Location" />
<Method name="toString" />
<Bug code="NP" />
</Match>
<!-- https://spotbugs.readthedocs.io/en/stable/filter.html#rank -->
<!-- TODO can we change this to higher rank or remove all together? -->
<Match>
<Rank value="16" />
</Match>
<!-- Example exclude class -->
<!-- <Match> -->
<!-- <Class name="gov.usgs.earthquake.nshmp.eq.fault.Faults" /> -->
<!-- </Match> -->
</FindBugsFilter>
apply plugin: "com.github.spotbugs"
/*
* Configure SpotBugs (FindBugs successor).
*
* See https://spotbugs.readthedocs.io
*/
spotbugs {
excludeFilter = file("${projectDir}/gradle/spotbugs-filter.xml")
effort = "max"
}
apply plugin: "com.diffplug.spotless"
/*
* Configure Spotless for code formatting checks based on the
* nshmp eclispe formatter (src/resources/nshmp.eclipse-format.xml).
*
* Spotless formatting check (spotlessCheck) is automatically
* ran on the pre-commit and pre-push git hooks.
*
* To fix any formatting issues run ./gradlew spotlessApply.
*
* See https://github.com/diffplug/spotless/tree/master/plugin-gradle
*/
spotless {
/* Java formatting */
java {
targetExclude "**/build", "bin", "**/Scratch*.java", "tmp", "libs"
removeUnusedImports()
custom "Refuse wildcard imports", {
if (it =~ /\nimport .*\*;/) {
throw new Error("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.");
}
}
importOrderFile "${projectDir}/src/main/resources/eclipse.importorder"
eclipse().configFile "${projectDir}/src/main/resources/nshmp.eclipse-format.xml"
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
/* Gradle file formatting */
groovyGradle {
target "**/*.gradle"
targetExclude "**/build", ".gradle", "bin", "tmp"
greclipse()
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
/* .gitignore, Bash, and Dockerfile formatting */
format "misc", {
target "**/.gitgnore", "**/*.sh", "**/*Dockerfile"
targetExclude "**/build", ".gradle/**", ".settings", "tmp/**",
"libs/**", "node_modules"
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
replaceRegex "Too many blank lines", "^\\n\\n+", "\n"
}
/* XML formatting */
format "xml", {
target fileTree(".") {
include "**/*.xml"
exclude "**/build", ".settings", ".classpath", ".project",
"tmp/**", ".gradle/**", "libs/**", "node_modules"
}
eclipseWtp("xml")
trimTrailingWhitespace()
indentWithSpaces(2)
endWithNewline()
}
}
#Organize Import Order
0=java
1=javax
2=org
3=com
4=gov
5=ucar
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment