-
Notifications
You must be signed in to change notification settings - Fork 36
/
build.gradle
233 lines (201 loc) · 8.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
/*
* (C) Copyright IBM Corp. 2020, 2021
*
* SPDX-License-Identifier: Apache-2.0
*/
plugins {
// Apply the java-library plugin to add support for Java Library
id 'java'
id 'java-library'
id 'jacoco'
id 'maven-publish'
id 'signing'
}
group = 'io.github.linuxforhealth'
version = (findProperty('version') == 'unspecified') ? '1.0.1-SNAPSHOT' : version
ext.isReleaseVersion = !version.endsWith("SNAPSHOT")
sourceCompatibility = 11
targetCompatibility = 11
dependencies {
// This dependency is exported to consumers, that is to say found on their compile classpath.
api 'org.apache.commons:commons-math3:3.6.1'
// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation 'com.google.guava:guava:32.0.0-jre'
implementation group: 'commons-io', name: 'commons-io', version: '2.7'
implementation 'ca.uhn.hapi:hapi-base:2.3'
implementation 'ca.uhn.hapi:hapi-structures-v26:2.3'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.1'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.1'
implementation group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.15.0'
api 'com.fasterxml.jackson.core:jackson-databind:2.13.4.2'
// https://mvnrepository.com/artifact/org.apache.commons/commons-text
implementation group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'
// https://mvnrepository.com/artifact/ca.uhn.hapi.fhir/hapi-fhir-structures-r4
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r4', version: '6.6.2'
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-structures-r5', version: '6.6.2'
// https://mvnrepository.com/artifact/ca.uhn.hapi.fhir/hapi-fhir-validation
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-validation', version: '6.6.2'
// https://mvnrepository.com/artifact/ca.uhn.hapi.fhir/hapi-fhir-validation-resources-r4
implementation group: 'ca.uhn.hapi.fhir', name: 'hapi-fhir-validation-resources-r4', version: '6.6.2'
// pin org.thymeleaf:[email protected] for CVE-2023-38286
implementation group: 'org.thymeleaf', name: 'thymeleaf', version: '3.1.2.RELEASE'
implementation group: 'org.apache.commons', name: 'commons-jexl3', version: '3.1'
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.8.0'
// https://mvnrepository.com/artifact/org.apache.commons/commons-configuration2
implementation group: 'org.apache.commons', name: 'commons-configuration2', version: '2.8.0'
// https://mvnrepository.com/artifact/org.apache.commons/commons-collections4
implementation group: 'org.apache.commons', name: 'commons-collections4', version: '4.4'
// https://mvnrepository.com/artifact/org.apache.commons/commons-compress
implementation group: 'org.apache.commons', name: 'commons-compress', version: '1.21'
implementation group:'com.ibm.fhir', name:'fhir-registry', version:'4.10.2'
implementation group:'com.ibm.fhir', name:'fhir-term', version:'4.10.2'
implementation group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.4'
testImplementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.4.0'
testImplementation 'org.assertj:assertj-core:3.9.0'
testImplementation "org.junit.jupiter:junit-jupiter-api:5.8.2"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.8.2"
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.8.2"
}
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
}
// Overriding the source directories to the target.
// This will cause the build/compile to use target instead of src.
if(!localDevEnv.toBoolean()) {
println "Overriding sourceset to the target directory"
sourceSets.main.java.srcDirs = ['target/main/java'];
sourceSets.main.resources.srcDirs = ['target/main/resources'];
} else {
println "localDevEnv is true - Setting sourceset to the src directory"
sourceSets.main.java.srcDirs = ['src/main/java', 'src/tools'];
sourceSets.main.resources.srcDirs = ['src/main/resources'];
}
test {
useJUnitPlatform()
// Use parallel processing as possible
maxParallelForks = (int) (Runtime.runtime.availableProcessors() / 2 + 1)
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.enabled false
csv.enabled false
html.destination file("${buildDir}/jacocoHtml")
}
}
publishing {
repositories {
maven {
name = "OSSRH"
def releaseRepo = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
def snapshotRepo = "https://oss.sonatype.org/content/repositories/snapshots/"
url = isReleaseVersion ? releaseRepo : snapshotRepo
credentials {
username = System.getenv("MAVEN_USERNAME")
password = System.getenv("MAVEN_PASSWORD")
}
}
}
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}
javadoc.failOnError = false
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
javadoc.options.addStringOption('noindex', '-quiet')
}
artifacts {
archives sourcesJar
archives javadocJar
}
publishing {
publications {
mavenPublication(MavenPublication) {
from components.java
artifact sourcesJar {
classifier "sources"
}
artifact javadocJar {
classifier "javadoc"
}
groupId = group
artifactId 'hl7v2-fhir-converter'
version = version
pom {
name = "hl7v2-fhir-converter"
description = "FHIR converter is a Java based library that enables converting Hl7v2 messages to FHIR resources"
url = "https://github.com/LinuxForHealth/hl7v2-fhir-converter"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "pbhallam"
}
}
scm {
url = "https://github.com/LinuxForHealth/hl7v2-fhir-converter.git"
}
}
}
}
}
signing {
if (isReleaseVersion ) {
def signingKeyId = System.getenv("signingKeyId")
def signingKey = System.getenv("signingKey")
def signingPassword = System.getenv("signingPassword")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
}
sign publishing.publications.mavenPublication
}
tasks.withType(Sign) {
onlyIf { isReleaseVersion }
}
task deleteTarget(type: Delete) {
description("Deletes the target directory")
if(!localDevEnv.toBoolean()) {
println 'Deleting target directory'
delete "target"
}
}
task resourcesCopy(type: Copy) {
description("Copies source to the target.")
if(!localDevEnv.toBoolean()) {
println 'Copying source to target'
copy {
from 'src'
into 'target'
}
}
}
task deleteJavaDebugLogs {
description("This function will delete all DEBUG log statements from the project.")
if(!localDevEnv.toBoolean()) {
println 'Stripping DEBUG statements out of target/main'
FileTree javaFiles = fileTree('target/main') {
include '**/*.java'
}
String regex = "(?ms)(LOGGER.debug.*?;)"
javaFiles.each { File javaFile ->
println "Start replacing regex on $javaFile.name"
String content = javaFile.getText()
content = content.replaceAll(regex, "")
javaFile.setText(content)
}
}
}
// Strip DEBUG log statements out
project.tasks.build.dependsOn project.tasks.deleteJavaDebugLogs
//BUT FIRST copy src to target
project.tasks.deleteJavaDebugLogs.dependsOn project.tasks.resourcesCopy
//BUT FIRST delete target directory
project.tasks.resourcesCopy.dependsOn project.tasks.deleteTarget