-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
260 lines (226 loc) · 8.05 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
/*
* xnat-on-fhir: build.gradle
*/
buildscript {
ext {
vXnat = "1.8.6"
}
}
// This is the minimum set of Gradle plugins required to build most XNAT plugins.
plugins {
id "jacoco"
id "java"
id "com.palantir.git-version" version "0.12.1"
id "io.franzbecker.gradle-lombok" version "4.0.0"
id "io.spring.dependency-management" version "1.0.11.RELEASE"
id "org.nrg.xnat.build.xnat-data-builder" version "1.8.6"
}
group 'de.htwberlin.cbmi'
version '0.2-alpha2'
description 'XNAT FHIR Plugin'
// This provides access to all of these repositories for dependency resolution.
repositories {
mavenLocal()
maven { url "https://nrgxnat.jfrog.io/nrgxnat/libs-release" }
maven { url "https://nrgxnat.jfrog.io/nrgxnat/libs-snapshot" }
mavenCentral()
}
// This defines a dependency package, specifically the XNAT NRG parent pom, which specifies
// versions for all of XNAT's dependencies. This helps ensure that plugins are building
// against the same versions of various libraries as XNAT itself.
dependencyManagement.imports {
mavenBom "org.nrg:parent:${vXnat}"
}
dependencies {
implementation enforcedPlatform("org.nrg:parent:${vXnat}")
implementation("org.nrg.xnat:web") {
transitive = false
}
implementation("org.nrg:dicom-xnat-mx") {
transitive = false
}
implementation("org.nrg.xnat:xnat-data-models") {
transitive = false
}
implementation "org.nrg.xdat:core"
implementation "org.nrg:dicom-xnat-util"
implementation "org.nrg:prefs"
implementation "org.nrg:framework"
implementation "dcm4che:dcm4che-core"
implementation "io.springfox:springfox-swagger2"
implementation "io.springfox:springfox-swagger-ui"
implementation("org.reflections:reflections") {
transitive = false
}
implementation("javax.servlet:javax.servlet-api") {
transitive = false
}
implementation("javax.json:javax.json-api:1.1") {
transitive = false
}
implementation("org.glassfish:javax.json:1.1") {
transitive = false
}
compileOnly "log4j:log4j"
testImplementation "org.junit.jupiter:junit-jupiter-api"
testImplementation "org.springframework:spring-test"
testImplementation "org.mockito:mockito-core"
testImplementation "org.assertj:assertj-core"
testImplementation "com.h2database:h2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly "ch.qos.logback:logback-classic"
}
// Pulls in the BUILD_NUMBER environment variable if available.
def buildDate = new Date()
def buildNumber = System.getenv().BUILD_NUMBER?.toInteger() ?: "Manual"
def isDirty, branchName, gitHash, gitHashFull, commitDistance, lastTag, isCleanTag
try {
def gitDetails = versionDetails()
isDirty = gitVersion().endsWith ".dirty"
branchName = gitDetails.branchName ?: "Unknown"
gitHash = gitDetails.gitHash
gitHashFull = gitDetails.gitHashFull
commitDistance = gitDetails.commitDistance
lastTag = gitDetails.lastTag
isCleanTag = gitDetails.isCleanTag
} catch (IllegalArgumentException e) {
logger.info "Got an error trying to read VCS metadata from git. It's possible this project is not under VCS control. Using placeholder values for manifest entries."
isDirty = true
branchName = "Unknown"
gitHash = "None"
gitHashFull = "None"
commitDistance = 0
lastTag = "None"
isCleanTag = false
}
ext.gitManifest = manifest {
attributes "Application-Name": project.description,
"Build-Date": buildDate,
"Build-Number": buildNumber,
"Implementation-Version": project.version,
"Implementation-Sha": gitHash,
"Implementation-Sha-Full": gitHashFull,
"Implementation-Commit": commitDistance,
"Implementation-LastTag": lastTag,
"Implementation-Branch": branchName,
"Implementation-CleanTag": isCleanTag,
"Implementation-Dirty": isDirty
}
logger.info """
Building artifacts with manifest attributes:
* Build-Date: ${buildDate}
* Build-Number: ${buildNumber}
* Implementation-Version: ${version}
* Implementation-Sha-Full: ${gitHashFull}
* Implementation-Sha: ${gitHash}
* Implementation-Commit: ${commitDistance}
* Implementation-LastTag: ${lastTag}
* Implementation-Branch: ${branchName}
* Implementation-CleanTag: ${isCleanTag}
* Implementation-Dirty: ${isDirty}
"""
// This configures the compileJava task to call the xnatDataBuilder task before
// trying to compile any Java code in the plugin and generates java and resources
// custom datatypes
compileJava.dependsOn project.tasks["xnatDataBuilder"]
configurations {
all {
exclude group: "net.logstash.logback"
exclude group: "org.nrg.xnat.pipeline"
exclude group: "org.slf4j", module: "jcl-over-slf4j"
exclude group: "org.slf4j", module: "log4j-over-slf4j"
exclude group: "org.slf4j", module: "slf4j-log4j12"
exclude group: "org.slf4j", module: "slf4j-simple"
}
implementation.extendsFrom(implementAndInclude)
}
lombok {
version = dependencyManagement.importedProperties["lombok.version"] as String
sha256 = dependencyManagement.importedProperties["lombok.checksum"] as String
}
jacocoTestReport {
dependsOn test
reports {
xml.required = false
csv.required = true
html.required = true
}
}
// This includes all the resource files generated by the xnatDataBuilder task
// in the build
sourceSets {
main {
resources {
srcDir "$buildDir/xnat-generated/src/main/resources"
}
}
}
java {
// As of the 1.8.x release, XNAT is built as a Java 8-compatible (i.e. JDK 1.8)
// application. All plugins must be 1.8 compatible as well. This does NOT mean
// the code must be compiled with Java 8, just that the compiled byte code must
// be compatible with running in a Java 8 environment.
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
// This builds a sources jar that pulls in the manifest with VCS info from above.
task sourcesJar(type: Jar, dependsOn: classes) {
classifier "sources"
manifest {
from gitManifest
}
from sourceSets.main.allSource
}
// This builds a javadoc jar that pulls in the manifest with VCS info from above.
task javadocJar(type: Jar) {
classifier "javadoc"
manifest {
from gitManifest
}
from javadoc.destinationDir
}
// This builds a regular classes jar that pulls in the manifest with VCS info from above.
// For the most part this jar isn't necessary: what you really want is the plugin jar.
jar {
dependsOn test, sourcesJar, javadocJar
enabled = true
manifest {
from gitManifest
}
}
// This builds the XNAT plugin jar that pulls in the manifest with VCS info from above.
// This includes all compiled Java classes (including generated classes), any schema
// files, JavaScript and Velocity template resources, and the XNAT plugin identifier
// properties file
task xnatPluginJar(type: Jar) {
dependsOn test, sourcesJar, javadocJar
zip64 true
manifest {
from gitManifest
}
from {
configurations.implementAndInclude.collect { it.isDirectory() ? it : zipTree(it) }
} {
exclude "META-INF/*.SF"
exclude "META-INF/*.DSA"
exclude "META-INF/*.RSA"
}
with jar
}
// Helper to debug source set issues
task printSourceSetInformation(){
doLast {
sourceSets.each { srcSet ->
println "["+srcSet.name+"]"
println "java.srcDirs = "+srcSet.java.srcDirs
println "resources.srcDirs = "+srcSet.resources.srcDirs
println "java.files = "+srcSet.java.files.name
println "allJava.files = "+srcSet.allJava.files.name
println "resources.files = "+srcSet.resources.files.name
println "allSource.files = "+srcSet.allSource.files.name
println "output.resourcesDir = "+srcSet.output.resourcesDir
println "output.files = "+srcSet.output.files
println ""
}
}
}