This repository has been archived by the owner on Sep 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.gradle
239 lines (206 loc) · 6.42 KB
/
build.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* User Manual available at https://docs.gradle.org/5.2.1/userguide/tutorial_java_projects.html
*/
plugins {
// java application
id "application"
// jar bundling
id "com.github.johnrengelman.shadow" version "7.1.2"
// code coverage
id "jacoco"
//
id "com.kageiit.jacobo" version "2.1.0"
// static code analysis
id "pmd"
// git clone, etc.
id "org.ajoberstar.grgit" version "2.3.0"
// google java format
id "com.github.sherter.google-java-format" version "0.9"
// manage micronaut dependencies
id "io.spring.dependency-management" version "1.0.11.RELEASE"
// support publishing to maven repositories
id 'maven-publish'
}
sourceCompatibility = "1.11"
targetCompatibility = "1.11"
version = "0.4.1"
repositories {
mavenCentral()
maven {
// The general NEIC package registry
url 'https://code.usgs.gov/api/v4/projects/8197/packages/maven'
}
}
configurations {
codacy
}
dependencyManagement {
imports {
mavenBom "io.micronaut:micronaut-bom:3.4.4"
}
}
dependencies {
// micronaut
annotationProcessor "io.micronaut:micronaut-inject-java"
annotationProcessor "io.micronaut:micronaut-validation"
annotationProcessor("io.micronaut.openapi:micronaut-openapi:3.2.0")
implementation "io.micronaut:micronaut-inject"
implementation "io.micronaut:micronaut-validation"
implementation "io.micronaut:micronaut-runtime"
implementation "io.micronaut:micronaut-http-client"
implementation "io.micronaut:micronaut-http-server-netty"
implementation "io.swagger.core.v3:swagger-annotations"
implementation "ch.qos.logback:logback-classic:1.2.9"
// com.googlecode.json.simple
implementation "com.googlecode.json-simple:json-simple:1.1.1"
// org.apache.commons.math3
implementation "org.apache.commons:commons-math3:3.6.1"
// gov.nist.math.jama
implementation "gov.nist.math:jama:1.0.3"
// travel times
implementation 'gov.usgs:neic-traveltime:0.9.0'
// earthquake processing formats
implementation 'gov.usgs:processingformats:0.1.0'
// earthquake detection formats
implementation 'gov.usgs:detectionformats:0.1.0'
// log4j2 (must be greater than 2.17.0)
implementation 'org.apache.logging.log4j:log4j-core:2.17.2'
implementation 'org.apache.logging.log4j:log4j-api:2.17.2'
// Use JUnit 5
testAnnotationProcessor "io.micronaut:micronaut-inject-java"
testImplementation("org.junit.jupiter:junit-jupiter-api")
testImplementation("io.micronaut.test:micronaut-test-junit5:3.0.5")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.2")
}
// method to add/update an external project from git and add it to the
// sourceset
ext.addExternalProject = { path, url, branch, srcDir ->
File projDir = new File("$path")
// cleanup local copy if it exists
// (we do this because grgit.pull doesn't seem to update
// local files, yes this is slow)
if(projDir.exists()) {
projDir.deleteDir()
}
// clone external project
logger.quiet('Cloning {}', projDir)
grgit.clone(dir: projDir, uri: url, refToCheckout: branch)
// add to sourceset
sourceSets {
main {
java {
srcDirs "$path/$srcDir"
}
}
}
}
// mainClassName = "gov.usgs.locatorservice.Application"
mainClassName = "gov.usgs.locator.LocMain"
// always format to google style prior to the build
compileJava.dependsOn 'googleJavaFormat'
// Google java style is checked automatically as part of the check task
project.tasks.check.dependsOn(verifyGoogleJavaFormat)
// coverage reports
jacoco {
toolVersion "0.8.2"
}
jacocoTestReport {
reports {
// Note I think these will need to be changed
// to .required = true when/if we move to
// gradle 8
html.enabled true
xml.enabled true
}
}
check.dependsOn jacocoTestReport
pmd {
toolVersion = "6.29.0"
ruleSets = [
file("pmd-ruleset.xml")
]
}
test {
useJUnitPlatform()
filter {
includeTestsMatching "*Test"
}
}
// unzip large model files
task unzipModelFiles(type: Copy) {
description "Decompresses large slab model files."
def zipFile = file('models/slabmaster.zip')
def outputDir = file('models')
from zipTree(zipFile)
into outputDir
}
// copy required model files
task copyModelFiles(type: Copy) {
description "Copies required model files to build directory."
from "models"
exclude "README.txt"
into "$buildDir/models"
}
// make sure we always update the external projects and copy models prior to
// complile
defaultTasks "unzipModelFiles", "copyModelFiles"
copyModelFiles.dependsOn "unzipModelFiles"
compileJava.dependsOn "copyModelFiles", "unzipModelFiles"
// show compile warnings
tasks.withType(JavaCompile) {
options.compilerArgs.add("-parameters")
options.encoding = "UTF-8"
options.setDeprecation(true);
options.setWarnings(true);
}
shadowJar {
mergeServiceFiles()
}
// create javadocs
javadoc {
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
options.addBooleanOption('html5', true)
}
}
// convert jacoco to cobertura
import com.kageiit.jacobo.JacoboTask
tasks.create("jacobo", JacoboTask, {
it.jacocoReport = file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml")
it.coberturaReport = file("${project.buildDir}/reports/cobertura/cobertura.xml")
it.srcDirs = sourceSets.main.java.srcDirs
}).dependsOn(jacocoTestReport)
project.tasks.check.dependsOn jacobo
// create model file zip for distribution
task zipModels(type: Zip, dependsOn: jar) {
archiveFileName = "Models.zip"
// example listeners
from ("models") { include "*.txt", "*.mod", "*.json", "*.dat"}
}
// publish to our maven package repository
// note this will only work from within the pipeline
publishing {
publications {
library(MavenPublication) {
from components.java
}
}
repositories {
maven {
// The general NEIC package registry
url "https://code.usgs.gov/api/v4/projects/8197/packages/maven"
name "GitLab"
credentials(HttpHeaderCredentials) {
name = 'Job-Token'
value = System.getenv("CI_JOB_TOKEN")
}
authentication {
header(HttpHeaderAuthentication)
}
}
}
}
publish.dependsOn "zipModels"