forked from synthetichealth/synthea
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
316 lines (282 loc) · 11.2 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
/*
* This build file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/3.5/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
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 {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenCentral()
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
checkstyle {
toolVersion '8.4'
//showViolations = true
}
dependencies {
// This dependency is found on compile classpath of this component and consumers.
compile 'com.google.code.gson:gson:2.8.0'
compile 'com.jayway.jsonpath:json-path:2.4.0'
compile 'ca.uhn.hapi.fhir:hapi-fhir-base:4.1.0'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu3:4.1.0'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-dstu2:4.1.0'
compile 'ca.uhn.hapi.fhir:hapi-fhir-structures-r4:4.1.0'
compile 'ca.uhn.hapi.fhir:hapi-fhir-client:4.1.0'
// C-CDA export uses Apache FreeMarker templates
compile 'org.freemarker:freemarker:2.3.26-incubating'
compile group: 'com.h2database', name: 'h2', version: '1.4.196'
// google guava for some data structures
compile 'com.google.guava:guava:23.0'
compile group: 'guru.nidi', name: 'graphviz-java', version: '0.2.2'
// CSV Stuff
compile group: 'org.apache.commons', name: 'commons-csv', version: '1.5'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-csv', version: '2.8.8'
compile group: 'org.yaml', name: 'snakeyaml', version: '1.25'
compile group: 'org.apache.commons', name: 'commons-math3', version: '3.6.1'
compile group: 'org.apache.commons', name: 'commons-text', version: '1.2'
compile group: 'org.opencds.cqf', name: 'cql-engine', version: '1.3.12'
compile group: 'info.cqframework', name: 'cql', version: '1.3.17'
compile group: 'info.cqframework', name: 'model', version: '1.3.17'
compile group: 'info.cqframework', name: 'cql-to-elm', version: '1.3.17'
// Java 9 no longer includes these APIs by default
compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.0'
compile 'org.glassfish.jaxb:jaxb-runtime:2.3.0'
compile 'javax.activation:activation:1.1.1'
// 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
compile "org.slf4j:slf4j-api:1.6.1"
// compile "org.slf4j:slf4j-nop:1.6.1" // SLF4J seems to already be provided by org.apache.logging.log4j
// Physiology simulation dependencies
compile files('lib/sbscl/SimulationCoreLibrary_v1.5_slim.jar')
compile group: 'org.sbml.jsbml', name: 'jsbml', version: '1.4', {
exclude group: 'org.apache.logging.log4j', module: 'log4j-slf4j-impl'
}
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
// JfreeChart for drawing physiology charts
compile group: 'org.jfree', name: 'jfreechart', version: '1.5.0'
// Use JUnit test framework
testCompile 'junit:junit:4.12'
testCompile fileTree(dir: 'lib/mdhtruntime/mdht', include: '*.jar')
testCompile fileTree(dir: 'lib/mdhtruntime/non-mdht', include: '*.jar')
testCompile 'org.mockito:mockito-core:2.19.0'
testCompile 'org.powermock:powermock-module-junit4:1.7.1'
testCompile 'org.powermock:powermock-api-mockito2:1.7.1'
testCompile 'com.github.tomakehurst:wiremock-jre8:2.26.3'
testCompile 'ca.uhn.hapi.fhir:hapi-fhir-validation:4.1.0'
testCompile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu3:4.1.0'
testCompile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-dstu2:4.1.0'
testCompile 'ca.uhn.hapi.fhir:hapi-fhir-validation-resources-r4:4.1.0'
testCompile 'com.helger:ph-schematron:5.0.4'
testCompile '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 = "2048m"
}
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']}"
)
}
baseName = 'synthea-with-dependencies'
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
task concepts(type: JavaExec) {
group 'Application'
description 'Create a list of simulated concepts'
classpath sourceSets.main.runtimeClasspath
main = "org.mitre.synthea.helpers.Concepts"
}
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)
}
}
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 = '2.6.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
}