-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.gradle
188 lines (152 loc) · 5.51 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
buildscript {
repositories {
mavenLocal()
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath files('libs/code-gen-gradle-plugin-0.2.2.25.jar')
classpath files('libs/edu.kit.ifv.codegen-0.2.2.90.jar')
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'jacoco'
group = 'edu.kit.ifv.mobitopp'
wrapper.gradleVersion = '6.3'
sourceCompatibility = 1.12
targetCompatibility = 1.12
repositories {
mavenLocal()
mavenCentral()
flatDir {
dirs 'libs'
}
}
configurations.all {
exclude group: 'xerces', module: 'xerces'
resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
}
dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.8'
compileOnly 'org.projectlombok:lombok:1.18.8'
implementation 'edu.kit.ifv.mobitopp:actitopp:1.9+',
'edu.kit.ifv.mobitopp:mobitopp:0.3+',
'net.sf.opencsv:opencsv:2.3'
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.0',
'org.hamcrest:hamcrest-all:1.3',
'org.assertj:assertj-core:3.15.0',
'org.mockito:mockito-core:3.3.0',
'org.mockito:mockito-junit-jupiter:3.3.0'
}
apply plugin: 'edu.kit.ifv.codegen.gradle.plugin'
codeGenInp {
outputDir = "${rootDir}/src/main/java"
files = [
// "${rootDir}/config/choice-models/access-carsharing.gen",
// "${rootDir}/config/choice-models/access-public-transport.gen",
// "${rootDir}/config/choice-models/bikesharing-membership.gen",
// "${rootDir}/config/choice-models/car-ownership.gen",
"${rootDir}/config/choice-models/carsharing_membership.gen",
"${rootDir}/config/choice-models/destination-choice.gen",
"${rootDir}/config/choice-models/mode_choice_mixed_logit_mode_preference.gen",
"${rootDir}/config/choice-models/mode_choice_mixed_logit_time_sensitivity.gen",
"${rootDir}/config/choice-models/mode_choice_mixed_logit.gen",
"${rootDir}/config/choice-models/multi-nomial-logit.gen"
// "${rootDir}/config/choice-models/transit_pass_ownership.gen"
]
}
compileJava.dependsOn('generateCode')
//-- Tasks ----------------------------------------------------------------------------
def pathToName(rel_path) {
return "run_" + rel_path.replace('/','_').replace('\\','_').replace('.yaml','')
}
def createLongTermModuleTask(configurationFile) {
def taskName = pathToName(configurationFile)
return tasks.create(taskName, JavaExec) {
args "config/${configurationFile}"
main = "edu.kit.ifv.mobitopp.populationsynthesis.LongTermModuleStarter"
}
}
def createShortTermModuleTask(configurationFile) {
def taskName = pathToName(configurationFile)
return tasks.create(taskName, JavaExec) {
args "config/${configurationFile}"
main = "edu.kit.ifv.mobitopp.simulation.ShortTermModule"
}
}
//create derived percent config files
def createFractionConfigFile(parent, fraction) {
def percent = Math.round(fraction * 100)
def path = parent.replace('.yaml','_' + percent + "p.yaml")
new File("${rootDir}/config/${path}").text =
"""
parent: config/$parent
fractionOfPopulation: $fraction
"""
return path
}
//create tasks for config files
fileTree("${rootDir}/config")
.filter{it.isFile()}
.filter{it.name.endsWith('.yaml')}
.each {
def rel_path = it.path.drop(it.path.lastIndexOf('config')+7)
def name = pathToName(rel_path)
if (name.contains('long')) {
createLongTermModuleTask(rel_path)
println "Created long-term-module task for " + rel_path
} else if (name.contains('short')) {
if (!rel_path.endsWith('p.yaml')) {
def path_1p = createFractionConfigFile(rel_path, 0.01)
def path_10p = createFractionConfigFile(rel_path, 0.1)
def path_100p = createFractionConfigFile(rel_path, 1)
createShortTermModuleTask(path_1p)
println "Created short-term-module task for " + path_1p
createShortTermModuleTask(path_10p)
println "Created short-term-module task for " + path_10p
createShortTermModuleTask(path_100p)
println "Created short-term-module task for " + path_100p
}
//createShortTermModuleTask(rel_path)
//println "Created short-term-module task " + rel_path
} else {
println "Could not determine whether the configuration " + name + " is short or long term module"
}
}
tasks.withType(JavaExec) {
classpath = sourceSets.main.runtimeClasspath
dependsOn check
enableAssertions = "true"
group = "application"
maxHeapSize="10G"
jvmArgs '-Xss512M'
jvmArgs '-XX:+UseG1GC'
jvmArgs '-Dnashorn.args="--no-deprecation-warning"'
}
//-- Tasks ----------------------------------------------------------------------------
//-- Run Files ------------------------------------------------------------------------
println("Creating run files")
mkdir "${rootDir}/run"
tasks.each {t ->
if(t.group == 'application') {
def name = t.name
println("create files for: ${name}")
new File("${rootDir}/run/${name}.bat").text =
"""
cd ..
call gradlew.bat clean --refresh-dependencies dependencies build $name
pause
"""
new File("${rootDir}/run/${name}.sh").text =
"""
#!/bin/bash
cd ..
./gradlew clean --refresh-dependencies dependencies build $name
read
"""
}
}
//-- Run Files ------------------------------------------------------------------------