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

Add gradle files

parent d5cc68ae
No related branches found
No related tags found
2 merge requests!577Production Release | nshmp-haz,!574Resolves - Gradle Build
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"
}
}
}
apply plugin: "com.github.node-gradle.node"
node {
download = true
version = "${nodeVersion}"
}
/* Install markdownlint-cli with NPM */
task nodeInstall(type: NpmTask) {
description "Install markdownlint-clia and yamllint with NPM"
args = [
"install",
"markdownlint-cli",
"yaml-lint",
"--save-dev",
"--loglevel",
"error"
]
}
/* Run markdownlint */
task markdownlint(type: NpxTask) {
description "Run markdownlint"
dependsOn nodeInstall
command = "markdownlint"
args = ["**/*.md"]
}
/* Apply markdownlint fixes */
task markdownlintApply(type: NpxTask) {
description "Apply markdownlint fixes"
dependsOn nodeInstall
command = "markdownlint"
args = [
"**/*.md",
"--fix",
]
}
/* Run yamllint */
task yamllint(type: NpxTask) {
description "Run yamllint"
dependsOn nodeInstall
command = "yamllint"
args = [
"**/*.yml",
"--ignore=.gradle/**",
"--ignore=node_modules/**",
]
}
<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