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
/
build.gradle
204 lines (175 loc) · 5.34 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
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn how to create Gradle builds at https://guides.gradle.org/creating-new-gradle-builds/
*/
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.9.0'
group = "gov.usgs"
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 {
codacy "com.codacy:codacy-coverage-reporter:4.0+"
// 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"
// earthquake processing formats
implementation 'gov.usgs:processingformats:0.1.0'
// 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")
}
// mainClassName = "gov.usgs.traveltimeservice.Application"
mainClassName = "gov.usgs.traveltime.TravelTimeMain"
// Note: To reformat all java code (not in lib) manually into the
// google java style, run ./gradlew goJF
googleJavaFormat {
exclude 'lib/**'
}
// always format to google style prior to the build
compileJava.dependsOn 'googleJavaFormat'
// Added Google java style check (shouldn't find anything)
project.tasks.check.dependsOn(verifyGoogleJavaFormat)
// coverage reports
jacoco {
toolVersion "0.8.7"
}
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
}
}
project.tasks.check.dependsOn jacocoTestReport
pmd {
toolVersion = "6.29.0"
ruleSets = [
file("pmd-ruleset.xml")
]
}
test {
useJUnitPlatform()
filter {
includeTestsMatching "*Test"
}
}
// method to copy required model files
task copyModelFiles(type: Copy) {
description 'Copies required model files to build directory.'
// dependsOn 'compileJava'
from "models"
exclude "README.txt"
into "$buildDir/models"
}
// show compile warnings
tasks.withType(JavaCompile) {
options.compilerArgs.add("-parameters")
options.encoding = "UTF-8"
options.setDeprecation(true);
options.setWarnings(true);
}
// make sure we always copy models prior to complile
defaultTasks "copyModelFiles"
compileJava.dependsOn "copyModelFiles"
shadowJar {
mergeServiceFiles()
}
// create javadocs
javadoc {
exclude "**/gov/usgs/processingformats/**"
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", "*.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"