forked from synthetichealth/synthea
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
335 lines (295 loc) · 11.5 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
/*
* 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
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
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"
}
}
checkstyle {
toolVersion '8.4'
//showViolations = true
}
jacoco {
toolVersion '0.8.6'
}
dependencies {
// This dependency is found on compile classpath of this component and consumers.
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'com.jayway.jsonpath:json-path:2.4.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-base:5.2.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:5.2.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:5.2.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-structures-r4:5.2.0'
implementation 'ca.uhn.hapi.fhir:hapi-fhir-client:5.2.0'
// C-CDA export uses Apache FreeMarker templates
implementation 'org.freemarker:freemarker:2.3.26-incubating'
// google guava for some data structures
implementation 'com.google.guava:guava:30.0-jre'
implementation 'guru.nidi:graphviz-java:0.2.4'
// CSV Stuff
implementation 'org.apache.commons:commons-csv:1.5'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-csv:2.8.8'
implementation 'org.yaml:snakeyaml:1.27'
implementation 'org.apache.commons:commons-math3:3.6.1'
implementation 'org.apache.commons:commons-text:1.2'
implementation 'commons-validator:commons-validator:1.4.0'
implementation 'org.opencds.cqf:cql-engine:1.3.12'
implementation 'info.cqframework:cql:1.3.17'
implementation 'info.cqframework:model:1.3.17'
implementation 'info.cqframework:cql-to-elm:1.3.17'
implementation 'org.springframework:spring-web:5.2.7.RELEASE'
// 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:2.3.2'
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:1.7.9"
// compile "org.slf4j:slf4j-nop:1.6.1" // SLF4J seems to already be provided by org.apache.logging.log4j
// Physiology simulation dependencies
implementation files('lib/sbscl/SimulationCoreLibrary_v1.5_slim.jar')
implementation 'org.sbml.jsbml:jsbml:1.5', {
exclude group:'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
}
implementation 'org.apache.commons:commons-math:2.2'
// JfreeChart for drawing physiology charts
implementation 'org.jfree:jfreechart:1.5.0'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
testImplementation fileTree(dir: 'lib/mdhtruntime/mdht', include: '*.jar')
testImplementation fileTree(dir: 'lib/mdhtruntime/non-mdht', include: '*.jar')
testImplementation 'org.mockito:mockito-core:2.19.0'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-mockito2:1.7.1'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.26.3'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation:5.2.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:5.2.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:5.2.0'
testImplementation 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:5.2.0'
testImplementation 'com.helger:ph-schematron:5.0.4'
testImplementation 'com.helger:ph-commons:9.1.1'
}
// Provide more descriptive test failure output
test {
testLogging {
exceptionFormat = 'full'
// showExceptions = true
// showCauses = true
// showStackTraces = true
// showStandardStreams = true
}
maxHeapSize = "6144m"
}
buildscript {
repositories {
jcenter()
}
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.enabled true
html.enabled true
}
}
check.dependsOn jacocoTestReport
task graphviz(type: JavaExec) {
group 'Application'
description 'Generate rule visualization'
classpath sourceSets.main.runtimeClasspath
main = "Graphviz"
}
task uberJar(type: Jar) {
def versionFile = new File("$projectDir/src/main/resources/version.txt")
def versionText = "N/A"
if (versionFile.exists()) {
versionText = versionFile.text.trim()
}
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']}"
)
}
archiveBaseName = 'synthea-with-dependencies'
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
duplicatesStrategy = 'warn'
}
task concepts(type: JavaExec) {
group 'Application'
description 'Create a list of simulated concepts'
classpath sourceSets.main.runtimeClasspath
main = "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
main = "org.mitre.synthea.helpers.Concepts"
args 'true'
}
task attributes(type: JavaExec) {
group 'Application'
description 'Create a list of patient attributes'
classpath sourceSets.main.runtimeClasspath
main = "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
main = "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
main = "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
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 = '3.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
}