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' }