forked from synthetichealth/synthea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
404 lines (358 loc) · 13.3 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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
/*
* This file defines the steps to build Synthea using Gradle. Full documentation of the syntax
* can be found at https://docs.gradle.org/6.5/userguide/java_plugin.html
*/
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
}
}
apply plugin: "com.github.johnrengelman.shadow"
// Apply the java plugin to add support for Java
apply plugin: 'java'
sourceCompatibility = '11'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'checkstyle'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'signing'
// In this section you declare where to find the dependencies of your project
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
// Uncomment to see deprecation warnings
// tasks.withType(JavaCompile) {
// options.compilerArgs << "-Xlint:deprecation"
// }
checkstyle {
toolVersion '8.4'
//showViolations = true
}
jacoco {
toolVersion '0.8.7'
}
dependencies {
// This dependency is found on compile classpath of this component and consumers.
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.jayway.jsonpath:json-path:2.7.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-base:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-r4:6.1.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-client:6.1.0'
// C-CDA export uses Apache FreeMarker templates
implementation 'org.freemarker:freemarker:2.3.31'
// google guava for some data structures
implementation 'com.google.guava:guava:31.1-jre'
implementation 'guru.nidi:graphviz-java:0.18.1'
// JavaScript engine included for graphviz. It gets used
// if someone does not have graphviz installed in their environment
implementation 'org.graalvm.js:js:22.2.0'
// CSV Stuff
implementation 'org.apache.commons:commons-csv:1.9.0'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.13.4'
implementation 'org.yaml:snakeyaml:1.32'
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.apache.commons:commons-text:1.9'
implementation 'commons-validator:commons-validator:1.7'
implementation 'org.opencds.cqf.cql:engine.jackson:2.0.0'
implementation 'org.opencds.cqf.cql:engine:2.0.0'
implementation 'info.cqframework:cql:2.1.0'
implementation 'info.cqframework:model:2.1.0'
implementation 'info.cqframework:cql-to-elm:2.1.0'
implementation 'info.cqframework:model-jackson:2.1.0'
implementation 'info.cqframework:elm-jackson:2.1.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
// Java 9 no longer includes these APIs by default
implementation 'javax.xml.bind:jaxb-api:2.4.0-b180830.0359'
implementation 'org.glassfish.jaxb:jaxb-runtime:4.0.0'
implementation 'javax.activation:javax.activation-api:1.2.0'
// get rid of SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
// if we switch to a real logging framework we may want to switch this
implementation "org.slf4j:slf4j-api:2.0.0"
//implementation "org.slf4j:slf4j-nop:1.7.9" // SLF4J seems to already be provided by org.apache.logging.log4j
// ensure transitive dependencies do not use vulnerable log4j
implementation "org.apache.logging.log4j:log4j-core", {
version {
strictly '2.17.0'
}
}
// Physiology simulation dependencies
implementation files('lib/sbscl/SimulationCoreLibrary_v1.5_slim.jar')
implementation 'org.sbml.jsbml:jsbml:1.6.1', {
exclude group:'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
exclude group:'junit', module: 'junit'
}
implementation 'org.apache.commons:commons-math:2.2'
// JfreeChart for drawing physiology charts
implementation 'org.jfree:jfreechart:1.5.3'
// Use JUnit test framework
testImplementation('junit:junit') {
version {
strictly '4.13.2'
}
}
testImplementation 'org.mockito:mockito-core:4.7.0'
testImplementation 'org.powermock:powermock-module-junit4:2.0.9'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.9'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.33.2'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation:6.1.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:6.1.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:6.1.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:6.1.0'
testImplementation 'com.helger:ph-schematron:5.6.5'
testImplementation 'com.helger:ph-commons:9.5.5'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
}
// Provide more descriptive test failure output
test {
testLogging {
exceptionFormat = 'full'
// showExceptions = true
// showCauses = true
// showStackTraces = true
// showStandardStreams = true
}
maxHeapSize = "6144m"
jacoco {
includes = ["org.mitre.*"]
}
}
buildscript {
repositories {
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
dependencies {
// commons-io used in getting the version id below
classpath group: 'commons-io', name: 'commons-io', version: '2.5'
// note that commons-io is already a dependency
// of commons-csv in the primary dependencies above
}
}
jacocoTestReport {
reports {
xml.required = true
html.required = true
}
}
check.dependsOn jacocoTestReport
task graphviz(type: JavaExec) {
group 'Application'
description 'Generate rule visualization'
classpath sourceSets.main.runtimeClasspath
mainClass = "Graphviz"
}
task rifMinimize(type: JavaExec) {
group 'Application'
description 'Filter exported RIF files to produce minimal set that covers all claim types'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.export.rif.tools.BB2RIFMinimizer"
}
task rif2CCW(type: JavaExec) {
group 'Application'
description 'Convert exported RIF files from BB2 format to CCW format'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.export.rif.tools.BB2RIF2CCW"
}
if (project.hasProperty("args")) {
ext.cmdLineArgs = project.getProperty("args")
} else {
ext.cmdLineArgs = ""
}
task rifBeneSplit(type: JavaExec) {
group 'Application'
description 'Split original 3 RIF file bene export into one file per year'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.export.rif.tools.BB2RIFBeneSplitter"
args cmdLineArgs.split()
}
shadowJar {
def versionFile = new File("$projectDir/src/main/resources/version.txt")
def versionText = "N/A"
if (versionFile.exists()) {
versionText = versionFile.text.trim()
}
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
archiveBaseName.set('synthea-with-dependencies')
archiveClassifier.set('')
archiveVersion.set('')
manifest {
attributes(
'Main-Class' : 'App',
'Build-Timestamp': new java.text.SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ").format(new Date()),
'Build-Version' : versionText,
'Created-By' : "Gradle ${gradle.gradleVersion}",
'Build-Jdk' : "${System.properties['java.version']} (${System.properties['java.vendor']} ${System.properties['java.vm.version']})",
'Build-OS' : "${System.properties['os.name']} ${System.properties['os.arch']} ${System.properties['os.version']}"
)
}
}
task uberJar() {
}
task concepts(type: JavaExec) {
group 'Application'
description 'Create a list of simulated concepts'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.helpers.Concepts"
args 'false'
}
task conceptswithoutcosts(type: JavaExec) {
group 'Application'
description 'Create a list of simulated concepts without costs'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.helpers.Concepts"
args 'true'
}
task attributes(type: JavaExec) {
group 'Application'
description 'Create a list of patient attributes'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.helpers.Attributes"
}
task overrides(type: JavaExec) {
group 'Application'
description 'Create a list of modules parameters in module override format'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.helpers.ModuleOverrides"
doFirst {
// TODO: is there a way to make this cleaner?
String includeFields = project.hasProperty('includeFields') ? project.getProperty('includeFields') : ""
String includeModules = project.hasProperty('includeModules') ? project.getProperty('includeModules') : ""
String excludeFields = project.hasProperty('excludeFields') ? project.getProperty('excludeFields') : ""
String excludeModules = project.hasProperty('excludeModules') ? project.getProperty('excludeModules') : ""
args(includeFields, includeModules, excludeFields, excludeModules)
}
}
task physiology(type: JavaExec) {
group 'Application'
description 'Test a physiology simulation'
classpath sourceSets.main.runtimeClasspath
mainClass = "org.mitre.synthea.engine.PhysiologySimulator"
}
task versionTxt() {
group 'Build'
description 'Generates a version file.'
doLast {
try {
// the ruby version uses `git rev-parse HEAD` which just produces the long commit hash.
// "git describe" can use tags or fallback to the commit hash if necessary.
// this assumes (as does the ruby version) that git will always be present when building
String[] cmd = ["git", "describe", "--tags", "--always"]
Process p = Runtime.getRuntime().exec(cmd)
p.waitFor()
def version = org.apache.commons.io.IOUtils.toString(p.getInputStream(), java.nio.charset.StandardCharsets.UTF_8)
def file = new File("$projectDir/src/main/resources/version.txt")
file.createNewFile()
file.text = version
} catch (e) {
// ex. if git is not installed, or if we can't write the file for some reason. it's not critical to the execution so don't crash
logger.warn("Warning: unable to create version.txt. Generated records will not indicate which version of Synthea was used to create them.")
logger.warn(e.getMessage())
}
}
}
compileJava.dependsOn versionTxt
uberJar.dependsOn versionTxt
uberJar.dependsOn shadowJar
task cleanOutput {
doLast {
delete fileTree(dir: 'output', include: '**/*')
}
}
// Define the main class for the application
mainClassName = 'App'
run {
// args are called "arams" because they are called with -P,
// ex. gradle run -Params="['arg1', 'args2']"
// see https://stackoverflow.com/questions/27604283/gradle-task-pass-arguments-to-java-application
if (project.hasProperty("arams")) {
args Eval.me(arams)
}
def maxHeapSizeVar = System.getenv("MAX_HEAP_SIZE")
if (maxHeapSizeVar != null) {
maxHeapSize = maxHeapSizeVar
}
}
task sourceJar(type: Jar) {
classifier "sources"
from sourceSets.main.allJava
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc.destinationDir
}
artifacts {
archives jar
archives sourceJar
archives javadocJar
}
def mavenGroup = 'org.mitre.synthea'
def mavenVersion = '4.0.0-SNAPSHOT'
publishing {
publications {
synthea(MavenPublication) {
groupId mavenGroup
version mavenVersion
from components.java
artifact(sourceJar) {
classifier = 'sources'
}
artifact(javadocJar) {
classifier = 'javadoc'
}
pom {
name = 'Synthea'
description = 'Synthetic Patient Population Simulator'
url = 'https://github.com/synthetichealth/synthea'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
scm {
connection = 'scm:git:git://github.com/synthetichealth/synthea.git'
developerConnection = 'scm:git:ssh://github.com:synthetichealth/synthea.git'
url = 'http://github.com/synthetichealth/synthea/tree/master'
}
developers {
developer {
name = 'Jason Walonoski'
email = '[email protected]'
organization = 'The MITRE Corporation'
organizationUrl = 'http://www.mitre.org/'
}
}
}
}
}
repositories {
maven {
def snapshotUrl = 'https://oss.sonatype.org/content/repositories/snapshots'
def releaseUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
url mavenVersion.endsWith('SNAPSHOT') ? snapshotUrl : releaseUrl
credentials {
def user = project.hasProperty('sonatypeUsername') ? sonatypeUsername : ''
def pw = project.hasProperty('sonatypePassword') ? sonatypePassword : ''
username user
password pw
}
}
}
}
signing {
required { project.hasProperty('signing.keyId') }
sign publishing.publications.synthea
}