-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
304 lines (262 loc) · 8.31 KB
/
Copy pathbuild.gradle
File metadata and controls
304 lines (262 loc) · 8.31 KB
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
plugins {
id 'java-library'
id 'java-test-fixtures'
id 'groovy'
id 'maven-publish'
id 'checkstyle'
id 'codenarc'
id 'com.github.spotbugs' version '4.6.2'
id 'eclipse'
id 'idea'
id 'com.google.protobuf' version '0.8.15' apply false
}
allprojects {
group = 'org.jlab.epsci'
version = '1.0-SNAPSHOT'
defaultTasks 'build'
repositories {
mavenLocal()
mavenCentral()
}
configurations.all {
resolutionStrategy {
force 'org.zeromq:jeromq:0.5.4'
}
}
}
java {
withSourcesJar()
withJavadocJar()
}
publishing {
publications {
maven(MavenPublication) {
from components.java
}
}
}
test {
testLogging {
exceptionFormat = 'full'
}
useJUnitPlatform {
excludeTags 'integration'
}
systemProperty 'spock.configuration', rootProject.file('config/test/SpockConfig.groovy')
}
task integrationTest(type: Test) {
useJUnitPlatform()
systemProperty 'spock.configuration', rootProject.file('config/test/SpockConfigIntegration.groovy')
testLogging {
exceptionFormat = 'full'
}
outputs.upToDateWhen { false }
}
tasks.withType(GroovyCompile).configureEach {
options.incremental = true
}
task allDeps(type: DependencyReportTask) {}
task allDepInsight(type: DependencyInsightReportTask) {}
ext.libs = [
jeromq : 'org.zeromq:jeromq:0.5.4',
protobuf : 'com.google.protobuf:protobuf-java:4.28.2',
protoc : 'com.google.protobuf:protoc:4.28.2',
jopt : 'net.sf.jopt-simple:jopt-simple:5.0.4',
jsr305 : 'com.google.code.findbugs:jsr305:3.0.2',
prometheus_client : 'io.prometheus:simpleclient:0.16.0',
prometheus_httpserver: 'io.prometheus:simpleclient_httpserver:0.16.0',
prometheus_hotspot : 'io.prometheus:simpleclient_hotspot:0.16.0'
]
ext.test_libs = [
jupiter_api : 'org.junit.jupiter:junit-jupiter-api:5.7.1',
jupiter_engine: 'org.junit.jupiter:junit-jupiter-engine:5.7.1',
groovy : 'org.codehaus.groovy:groovy:3.0.7',
spock : 'org.spockframework:spock-core:2.0-M4-groovy-3.0',
hamcrest : 'org.hamcrest:hamcrest:2.2'
]
dependencies {
api 'org.jlab.coda:xmsg:2.4-SNAPSHOT'
api 'org.jline:jline:3.1.3'
api 'org.json:json:20201115'
implementation 'com.google.code.findbugs:findbugs-annotations:3.0.1'
implementation 'org.freemarker:freemarker:2.3.31'
implementation 'org.yaml:snakeyaml:1.28'
implementation 'org.apache.commons:commons-exec:1.3'
implementation 'org.jlab.coda:jinflux:1.0-SNAPSHOT'
implementation 'org.jetbrains:annotations:24.0.1'
implementation libs.jeromq // <-- explicitly added for runtime
implementation libs.prometheus_client
implementation libs.prometheus_httpserver
implementation libs.prometheus_hotspot
constraints {
codenarc(test_libs.groovy)
}
compileOnly libs.jsr305
testImplementation test_libs.jupiter_api
testImplementation test_libs.groovy
testImplementation test_libs.spock
testRuntimeOnly test_libs.jupiter_engine
testImplementation test_libs.hamcrest
}
def runGit(cmd) {
rootProject.file('.git').exists() ? cmd.execute().text.trim() : ''
}
ext {
gitBranch = properties['gitBranch'] ?: runGit('git rev-parse --abbrev-ref HEAD')
gitRev = properties['gitRev'] ?: runGit('git rev-parse --short=10 HEAD')
gitDescribe = properties['gitDescribe'] ?: runGit('git describe --match=v[0-9]* --abbrev=10 HEAD')
}
task generateVersionProperties {
def propertiesFile = file("${buildDir}/resources/main/META-INF/version.properties")
inputs.property 'version', project.version
inputs.property 'groupId', project.group
inputs.property 'artifactId', project.name
inputs.property 'gitBranch', gitBranch
inputs.property 'gitRev', gitRev
inputs.property 'gitDescribe', gitDescribe
outputs.file propertiesFile
doLast {
propertiesFile.write "version=${project.version}\n"
propertiesFile.append "groupId=${project.group}\n"
propertiesFile.append "artifactId=${project.name}\n"
propertiesFile.append "builtBy=${System.getProperty('user.name')}\n"
propertiesFile.append "builtJDK=${System.getProperty('java.version')}\n"
if (gitBranch) propertiesFile.append "git.branch=${gitBranch}\n"
if (gitRev) propertiesFile.append "git.revision=${gitRev}\n"
if (gitDescribe) propertiesFile.append "git.describe=${gitDescribe}\n"
}
}
tasks.named('javadoc') {
dependsOn 'generateVersionProperties'
inputs.dir("$buildDir/resources/main")
options.charSet = 'utf8'
options.encoding = 'utf8'
options.docEncoding = 'utf8'
}
tasks.named('checkstyleMain') {
dependsOn 'generateVersionProperties'
inputs.dir("$buildDir/resources/main")
}
jar.dependsOn generateVersionProperties
def deploySpec = copySpec {
into ('lib') {
from configurations.runtimeClasspath
from jar.archiveFile
}
from ('scripts/unix') {
into 'bin'
exclude 'etc'
fileMode 0755
}
from ('scripts/lib') {
into 'lib/ersap'
fileMode 0755
}
def tempDir = "${buildDir}/distributions/ersap_home"
file("${tempDir}/log").mkdirs()
file("${tempDir}/plugins").mkdirs()
from tempDir
}
task deploy(type: Copy) {
def dest = "$System.env.ERSAP_HOME"
into dest
with deploySpec
doFirst {
if (dest == 'null') {
throw new GradleException('ERSAP_HOME not set')
}
}
}
ext {
classPathCache = file("${buildDir}/tmp/classpath")
testClassPathCache = file("${buildDir}/tmp/test_classpath")
}
task cacheClasspath {
inputs.files sourceSets.main.runtimeClasspath
inputs.files sourceSets.test.runtimeClasspath
outputs.files classPathCache
outputs.files testClassPathCache
doLast {
classPathCache.write sourceSets.main.runtimeClasspath.asPath
testClassPathCache.write sourceSets.test.runtimeClasspath.asPath
}
}
task printClasspath {
doLast {
println classPathCache.text.replace(':', '\n')
}
dependsOn cacheClasspath
}
assemble.dependsOn cacheClasspath
ext {
ciMode = properties['ciMode'] ?: 'false'
}
checkstyle {
toolVersion = '8.41'
configFile = rootProject.file('config/quality/checkstyle.xml')
configProperties['samedir'] = rootProject.file('config/quality')
}
codenarc {
toolVersion = '2.0.0'
ignoreFailures = true
configFile = rootProject.file('config/quality/codenarc.groovy')
if (ciMode.toBoolean()) {
reportFormat 'console'
}
}
spotbugs {
toolVersion = '4.2.2'
ignoreFailures = true
effort = 'max'
reportLevel = 'medium'
excludeFilter = rootProject.file('config/quality/findbugs-exclude.xml')
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask) {
def useXml = ciMode.toBoolean()
reports {
xml.enabled = useXml
html.enabled = !useXml
}
}
task checkSpotBugsResults {
doLast {
def bugsFound = 0
allprojects.each { subproject ->
[subproject.tasks.findByName('spotbugsMain'), subproject.tasks.findByName('spotbugsTest')].each { task ->
if (task) {
try {
bugsFound += printSpotBugs task.reports.getByName('XML').destination
} catch (FileNotFoundException e) {
logger.info e.message
}
}
}
}
if (bugsFound > 0) {
throw new GradleException("$bugsFound SpotBugs rule violations were found.")
}
}
}
def printSpotBugs(File xml) {
def slurped = new XmlSlurper().parse(xml)
def bugs = slurped.BugInstance
bugs.each { bug ->
def line = bug.SourceLine
logger.error "[SpotBugs] ${line.@sourcepath}:${line.@start}:${line.@end} [${bug.@type}]"
}
bugs.size()
}
eclipse {
classpath {
file {
defaultOutputDir = file("${buildDir.name}/eclipse/default")
whenMerged { classpath ->
classpath.entries.each { source ->
if (source.kind == 'src' && source.hasProperty('output')) {
source.output = source.output.replace('bin', "${buildDir.name}/eclipse")
}
}
}
}
}
}