build.gradle 11.5 KB
Newer Older
Juon Kawakami's avatar
init  
Juon Kawakami committed
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
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
plugins {
  id 'java'
  id 'maven-publish'
}

defaultTasks 'completeBuild'

group = 'com.github.roborescue'

sourceCompatibility = '17'
targetCompatibility = '17'
version = '2.0'

def getDateTime() {
  new Date().format('yyyyMMddHHmmss', TimeZone.getTimeZone('UTC'))
}

dependencies {
  // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core
  implementation group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.13.0'

  // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind
  implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.13.0'

  // https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations
  implementation group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: '2.13.0'
  implementation 'com.google.code.gson:gson:2.8.9'
  implementation 'com.google.guava:guava:31.0.1-jre'
  implementation 'com.google.protobuf:protobuf-java:3.19.1'
  implementation 'com.google.protobuf:protobuf-java-util:3.19.1'
  implementation 'com.vividsolutions:jts:1.13'
  implementation 'jaxen:jaxen:1.2.0'
  implementation 'jfree:jfreechart:1.0.13'
  implementation 'log4j:log4j:1.2.17'
  implementation 'net.sf.trove4j:trove4j:2.1.0'
  implementation 'net.sourceforge.jsi:jsi:1.0.0'
  implementation 'org.dom4j:dom4j:2.1.3'
  implementation 'org.json:json:20210307'
  implementation 'org.jfree:jcommon:1.0.24'
  implementation 'org.jscience:jscience:4.3.1'
  implementation 'org.slf4j:slf4j-log4j12:1.7.32'
  implementation 'org.uncommons.maths:uncommons-maths:1.2.2'
  implementation 'org.tukaani:xz:1.9'
  implementation 'org.projectlombok:lombok:latest.integration'
  implementation 'org.apache.commons:commons-compress:1.21'
  annotationProcessor 'org.projectlombok:lombok:latest.integration'

  testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
  testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

repositories {
  mavenCentral()

  maven {
    url = 'http://sourceforge.net/projects/jsi/files/m2_repo'
    allowInsecureProtocol = true
  }
  maven {
    url = 'https://jitpack.io'
  }
}

sourceSets {
  main {
    java {
      srcDirs = [ 'modules/kernel/src',
                  'modules/handy/src',
                  'modules/misc/src',
                  'modules/rescuecore2/src',
                  'modules/standard/src',
                  'modules/clear/src',
                  'modules/collapse/src',
                  'modules/gis2/src',
                  'modules/ignition/src',
                  'modules/maps/src',
                  'modules/sample/src',
                  'modules/traffic3/src',
                  'modules/oldsims',
                  'modules/resq-fire/src'
                ]
    }
  }
}

test {
  useJUnitPlatform()
}

jar {
  manifest {
    attributes('Implementation-Title': project.name,
      'Implementation-Version': project.version + '-${getDateTime()}')
  }
}

javadoc {
  options {
    encoding = 'UTF-8'
    addStringOption('Xdoclint:none', '-quiet')
  }
}

publishing {
  publications {
    maven(MavenPublication) {
      groupId = 'com.github.roborescue'
      artifactId = 'rcrs-server'
      version = 'master-SNAPSHOT'

      from components.java
    }
  }
}

clean {
  doFirst {
    delete file( new File( rootDir, 'bin' ) )
    delete file( new File( rootDir, 'build' ) )
    delete file( new File( rootDir, 'jars' ) )
    delete file( new File( rootDir, 'lib' ) )
    delete file( new File( rootDir, 'test-results' ) )
  }
}

[compileJava, compileTestJava].each {
  it.options.encoding = 'UTF-8'
  it.options.compilerArgs += [ '-Xlint:deprecation' ]
}

task exportLibs(type: Copy) {
  from configurations.runtimeClasspath
  into 'lib'
}

/* Modules jar generation tasks */
task clearSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'clear/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'clear-sources.jar'
}

task clearJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'clear/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'clear.jar'
}

task collapseSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'collapse/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'collapse-sources.jar'
}

task collapseJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'collapse/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'collapse.jar'
}

task gis2SourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'gis2/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'gis2-sources.jar'
}

task gis2Jar(type: Jar) {
  from(sourceSets.main.output) {
    include 'gis2/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'gis2.jar'
}

task ignitionSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'ignition/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'ignition-sources.jar'
}

task ignitionJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'ignition/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'ignition.jar'
}

task kernelSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'kernel/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'kernel-sources.jar'
}

task kernelJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'kernel/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'kernel.jar'
}

task mapsSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'maps/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'maps-sources.jar'
}

task mapsJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'maps/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'maps.jar'
}

task miscSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'misc/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'misc-sources.jar'
}

task miscJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'misc/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'misc.jar'
}

task rescuecore2SourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'rescuecore2/**'
    exclude 'rescuecore2/standard/**'
  }
  into 'rescuecore2', {
    from 'modules/rescuecore2/resources/rescuecore2'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'rescuecore2-sources.jar'
}

task rescuecore2Jar(type: Jar) {
  from(sourceSets.main.output) {
    include 'rescuecore2/**'
    exclude 'rescuecore2/standard/**'
  }
  into 'rescuecore2', {
    from 'modules/rescuecore2/resources/rescuecore2'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'rescuecore2.jar'
}

task resqFireSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'rescuecore/**'
    include 'firesimulator/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'resq-fire-sources.jar'
}

task resqFireJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'rescuecore/**'
    include 'firesimulator/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'resq-fire.jar'
}

task sampleSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'sample/**'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'sample-sources.jar'
}

task sampleJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'sample/**'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'sample.jar'
}

task standardSourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'rescuecore2/standard/**'
  }
  into 'rescuecore2/standard', {
    from 'modules/standard/resources/rescuecore2/standard'
  }
  destinationDirectory = file('jars/sources')
  archiveFileName = 'standard-sources.jar'
}

task standardJar(type: Jar) {
  from(sourceSets.main.output) {
    include 'rescuecore2/standard/**'
  }
  into 'rescuecore2/standard', {
    from 'modules/standard/resources/rescuecore2/standard'
  }
  destinationDirectory = file('jars')
  archiveFileName = 'standard.jar'
}

task traffic3SourceJar(type: Jar, dependsOn: classes) {
  classifier = 'sources'
  from(sourceSets.main.allSource) {
    include 'traffic3/**'
  }
  from 'modules/traffic3/resources'
  destinationDirectory = file('jars/sources')
  archiveFileName = 'traffic3-sources.jar'
}

task traffic3Jar(type: Jar) {
  from(sourceSets.main.output) {
    include 'traffic3/**'
  }
  from 'modules/traffic3/resources'
  destinationDirectory = file('jars')
  archiveFileName = 'traffic3.jar'
}

/* Generate the compressed source in Jar files  */
task sourcesJar(type: GradleBuild) {
  tasks = [ 'clearSourceJar', 'collapseSourceJar', 'gis2SourceJar',
            'ignitionSourceJar', 'kernelSourceJar', 'mapsSourceJar',
            'miscSourceJar', 'rescuecore2SourceJar', 'resqFireSourceJar',
            'sampleSourceJar', 'standardSourceJar', 'traffic3SourceJar'
          ]
}

/* Perform a complete build of the simulator */
task completeBuild(type: GradleBuild) {
  tasks = [ 'clean', 'clearJar', 'collapseJar', 'gis2Jar', 'ignitionJar',
            'kernelJar', 'mapsJar', 'miscJar', 'rescuecore2Jar', 'resqFireJar',
            'sampleJar', 'standardJar', 'traffic3Jar', 'sourcesJar',
            'exportLibs'
          ]
}
if (project.hasProperty("args")) {
    ext.cmdargs = project.getProperty("args")
} else { 
    ext.cmdargs = '-c maps/test/config/kernel.cfg --gis.map.dir=maps/test/map --kernel.logname=logs/log/rescue.log.xz'
}

/* run simulator */
task run2(type: JavaExec) {
  classpath = files('jars')
  classpath = files('lib')
  classpath += files('.')
  classpath += sourceSets.main.runtimeClasspath
  mainClass = 'kernel.StartKernel'
  maxHeapSize = '2048m'
  jvmArgs '-Dlog4j.log.dir=logs/log'
  args(cmdargs.split(' '))
}

/* Generate a random scenario */
task randomScenario(type: JavaExec) {
  classpath = files('.')
  classpath += sourceSets.main.runtimeClasspath
  mainClass = 'gis2.scenario.RandomScenarioGenerator'
  maxHeapSize = '2048m'
  jvmArgs '-Dlog4j.log.dir=logs/log'
}

/* Open scenario editor */
task scenarioEditor(type: JavaExec) {
  classpath = files('.')
  classpath += sourceSets.main.runtimeClasspath
  mainClass = 'gis2.scenario.ScenarioEditor'
  maxHeapSize = '2048m'
  jvmArgs '-Dlog4j.log.dir=logs/log'
}

/* Open LogViewer */
task logViewer(type: JavaExec, dependsOn: classes) {
  classpath = files('.')
  classpath += sourceSets.main.runtimeClasspath
  mainClass = 'sample.SampleLogViewer'
  maxHeapSize = '10240m'
  jvmArgs '-Dlog4j.log.dir=logs/log'
  args = [ '-c', 'config/logviewer.cfg', '0715-052303-Ri-one-kobe2.xz']
}

/* Open gml editor */
task gmlEditor(type: JavaExec) {
  classpath = files('.')
  classpath += sourceSets.main.runtimeClasspath
  mainClass = 'maps.gml.editor.GMLEditor'
  maxHeapSize = '2048m'
  jvmArgs '-Dlog4j.log.dir=logs/log'
}

/* Converter OSM to GML */
task osm2gml(type: JavaExec) {
  classpath = files('.')
  classpath += sourceSets.main.runtimeClasspath
  mainClass = 'maps.convert.Convert'
  maxHeapSize = '2048m'
  jvmArgs '-Dlog4j.log.dir=logs/log'
}