-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle
366 lines (295 loc) · 9.17 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
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.standardout:gradle-eclipseconfig:1.1.1'
}
}
plugins {
id 'groovy'
id 'application'
id 'maven-publish'
//id 'osgi' // discontinued - do we need it?
id 'com.bmuschko.docker-java-application' version '9.4.0'
id "nebula.ospackage-application" version "9.1.1"
id 'org.ajoberstar.grgit' version '5.3.0'
id 'to.wetransform.semantic-release-version' version '2.1.2'
id 'com.diffplug.spotless' version '6.25.0'
}
apply plugin: 'org.standardout.eclipseconfig'
// use java 17
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
group = 'to.wetransform'
project.ext {
haleCoreVersion = '6.1.0-SNAPSHOT'
groovyVersion = '2.5.23'
}
/*
* Dependencies
*/
repositories {
// mavenLocal() //XXX for testing
maven {
// wetransform release repository (HALE releases and Eclipse dependencies)
url 'https://artifactory.wetransform.to/artifactory/local'
}
// this needs to be defined before jcenter/MavenCentral for retrieving JAI
maven {
url 'https://repo.osgeo.org/repository/release/'
}
mavenCentral()
}
configurations {
// exclude Saxon9 custom dependency by schema-utils (schematron validation)
implementation.exclude group: 'org.opengis.cite.saxon', module: 'saxon9'
}
dependencies {
// HALE
// BOM
implementation(platform("eu.esdihumboldt.hale:bom:$haleCoreVersion"))
/*
* Features
*/
// CLI and core hale libraries & resources
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.app.feature.cli"
// core I/O providers and core hale libraries & resources
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.feature.core"
// HTML export
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.feature.html"
/*
* Additional formats
*/
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.mssql"
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.jdbc.msaccess"
// Schematron validation
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.io.schematron"
// replacement for omitted Saxon dependency
// tested w/ schematron validation in https://github.com/wetransform/exp-schematron/tree/exp/saxon-he
implementation 'net.sf.saxon:Saxon-HE:9.9.1-8'
/*
* Other
*/
// user / customer specific
implementation "eu.esdihumboldt.hale:eu.esdihumboldt.hale.adv.merge"
// Groovy
implementation "org.codehaus.groovy:groovy-all:$groovyVersion"
// CLI
// implementation 'commons-cli:commons-cli:1.9.0'
// Groovy Shell
implementation 'jline:jline:2.14.6'
/*
* Testing
*/
testImplementation 'junit:junit:4.13.2'
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
}
configurations.all {
// ensure SNAPSHOTs are updated every time if needed
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
def defaultJvmArgs = [
'-Dcache.level1.enabled=false',
'-Dcache.level1.size=0',
'-Dcache.level2.enabled=false',
'-Dcache.level2.size=0',
'--add-exports=java.base/sun.nio.ch=ALL-UNNAMED',
'--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED'
]
mainClassName = 'to.wetransform.halecli.CLI'
applicationName = 'hale'
applicationDefaultJvmArgs = defaultJvmArgs
test {
// debug classloading
// jvmArgs '-verbose:class'
}
/*
* plugin.xml and OSGi manifest
*
* For the plugin.xml file to be recognised there must be an
* OSGi manifest. In the resources is a dummy file that is required
* for tests and execution from within Eclipse or Gradle.
* In the build Jar, the manifest file is overriden.
*/
jar {
manifest {
attributes 'Bundle-SymbolicName': 'to.wetransform.halecli;singleton:=true',
'Bundle-Vendor': 'wetransform GmbH'
}
}
/*
* OS packaging
*/
ospackage {
packageName = 'hale-cli'
link("/usr/local/bin/$applicationName", "/opt/$applicationName/bin/$applicationName")
link("/etc/bash_completion.d/hale", "/opt/$applicationName/etc/bash_completion.sh")
}
ospackage_application {
prefix = "/opt"
}
distributions {
main {
contents {
from(file('etc')) {
into 'etc'
}
}
}
}
/*
* Docker configuration
* see https://github.com/bmuschko/gradle-docker-plugin
*/
docker {
javaApplication {
// https://bmuschko.github.io/gradle-docker-plugin/current/user-guide/#extension_2
// switching to jre-jammy as the use pf Alpine as the OS of the hale-cli image breaks derived images that expect Ubuntu
baseImage = 'eclipse-temurin:17-jre-jammy'
maintainer = 'Simon Templer "[email protected]"'
images = [
"wetransform/${project.name}:${project.version}",
"wetransform/${project.name}:latest"
]
// apply JAVA_OPTS to docker plugin as the default args configured in build does not apply to docker plugin
jvmArgs = defaultJvmArgs
}
url = project.hasProperty('dockerHost') ? dockerHost : 'http://localdocker:2375'
registryCredentials {
url = 'https://index.docker.io/v1/'
username = project.hasProperty('dockerHubUsername') ? dockerHubUsername : ''
password = project.hasProperty('dockerHubPassword') ? dockerHubPassword : ''
email = project.hasProperty('dockerHubEmail') ? dockerHubEmail : ''
}
}
dockerCreateDockerfile {
def buildTime = java.time.ZonedDateTime.now().format(java.time.format.DateTimeFormatter.ISO_INSTANT)
label('git.sha': grgit.head().id, 'git.branch': grgit.branch.current.name, 'build.version': version, 'build.time': buildTime)
instruction 'COPY hale /hale/'
}
task dockerTagLatest(dependsOn: dockerBuildImage) {}
task dockerPushLatest(dependsOn: dockerPushImage) {}
/*
* Packaging and publishing
*/
// package groovydoc into a jar file
task packageJavadoc(type: Jar, dependsOn: 'groovydoc') {
from groovydoc.destinationDir
classifier = 'javadoc'
}
task dockerCopyDistResources(type: Copy) {
description "Copies the distribution resources to a temporary directory for image creation."
dependsOn installDist
from installDist.destinationDir.parentFile
into dockerCreateDockerfile.destFile.get().asFile.parentFile
exclude "**/lib/${jar.archiveFileName}"
into("app-lib") {
from jar
}
}
tasks.dockerSyncBuildContext {
finalizedBy dockerCopyDistResources
}
tasks.dockerBuildImage {
dependsOn dockerCopyDistResources
}
// package source into a jar file
task packageSources(type: Jar) {
from sourceSets.main.allSource
classifier = 'sources'
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
artifact packageSources
artifact packageJavadoc
}
}
repositories {
maven {
url = project.version.endsWith('-SNAPSHOT') ?
'https://artifactory.wetransform.to/artifactory/libs-snapshot-local' :
'https://artifactory.wetransform.to/artifactory/libs-release-local'
credentials {
username project.hasProperty('wetfArtifactoryUser') ? wetfArtifactoryUser : ''
password project.hasProperty('wetfArtifactoryPassword') ? wetfArtifactoryPassword : ''
}
}
}
}
// exclude distZip ands distTar artifacts
configurations.archives.with {
artifacts.remove artifacts.find { it.file == 'zip' }
artifacts.remove artifacts.find { it.file == 'tar' }
}
// Workaround for gradle application plugin 'the input line is too long' error on Windows
// see https://gist.github.com/jlmelville/2bfe9277e9e2c0ff79b6
tasks.withType(CreateStartScripts).each { task ->
task.doLast {
String text = task.windowsScript.text
text = text.replaceFirst(/(set CLASSPATH=%APP_HOME%\\lib\\).*/, { "${it[1]}*" })
task.windowsScript.write text
}
}
task uploadArchives {
dependsOn 'publish'
}
/*
* Gradle wrapper
*/
wrapper {
gradleVersion = '7.6.4'
}
/*
* Formatting
*/
def header = '''
/*
* Copyright (c) $YEAR wetransform GmbH
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution. If not, see <http://www.gnu.org/licenses/>.
*/
'''
// add header only if "@custom-license-header" is NOT present in file
def headerRegex = /^(?s)(?!.*@custom-license-header).*/
spotless {
java {
toggleOffOn()
importOrder('java', 'javax', 'org', 'com', '')
removeUnusedImports()
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-jdt
eclipse().configFile('eclipse-format.xml')
licenseHeader(header).onlyIfContentMatches(headerRegex)
trimTrailingWhitespace()
endWithNewline()
}
groovy {
toggleOffOn()
importOrder('groovy', 'java', 'javax', 'org', 'com', '')
// https://github.com/diffplug/spotless/tree/main/plugin-gradle#eclipse-groovy
greclipse().configFile('groovy-format.properties')
// excludes all Java sources within the Groovy source dirs from formatting
excludeJava()
licenseHeader(header).onlyIfContentMatches(headerRegex)
trimTrailingWhitespace()
endWithNewline()
}
groovyGradle {
toggleOffOn()
target '*.gradle'
greclipse().configFile('groovy-format.properties')
trimTrailingWhitespace()
endWithNewline()
}
}