openrocket/core/build.gradle

163 lines
6.6 KiB
Groovy

plugins {
id "com.github.johnrengelman.shadow"
id 'java'
id 'com.adarshr.test-logger' version '3.2.0'
id 'checkstyle'
}
group 'net.sf.openrocket'
Properties props = new Properties()
try {
props.load(file('./src/main/resources/build.properties').newDataInputStream())
} catch (Exception ex) {
throw new Exception("Missing build.properties. file: " + ex.getMessage())
}
version = props['build.version']
repositories {
mavenCentral()
}
checkstyle {
ignoreFailures = false
maxWarnings = 0
}
dependencies {
implementation group: 'org.commonmark', name: 'commonmark', version: '0.19.0' // 0.21.0
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.30' // 2.0.6
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1' // 3.12.0
implementation group: 'com.google.inject', name: 'guice', version: '4.2.2' // 4.2.3, 5.1.0
implementation group: 'com.opencsv', name: 'opencsv', version: '5.7.1'
implementation group: 'eu.infomas', name: 'annotation-detector', version: '3.0.5'
implementation group: 'org.graalvm.sdk', name: 'graal-sdk', version: '22.1.0.1' // 22.3.1
implementation group: 'org.graalvm.js', name: 'js-scriptengine', version: '22.1.0.1' // 22.3.1
// implementation group: 'javax.script', name: 'script-api', version: '1.0-osgi'
implementation group: 'org.graalvm.truffle', name: 'truffle-api', version: '22.1.0.1' // 22.3.1
implementation group: 'com.ibm.icu', name: 'icu4j', version: '71.1' // 72.1
implementation group: 'com.sun.istack', name: 'istack-commons-tools', version: '4.1.1' // TODO: Should be gotten rid of?
implementation group: 'com.sun.istack', name: 'istack-commons-runtime', version: '4.1.1' // TODO: Should be gotten rid of?
implementation group: 'javax.xml.bind', name: 'jaxb-api', version: '2.3.1'
implementation 'org.glassfish.jaxb:jaxb-runtime:2.3.1'
implementation 'org.glassfish:javax.json:1.1.3' // 1.1.4
implementation 'org.eclipse:yasson:1.0.2' // 2.0.1
implementation group: 'javax.activation', name: 'javax.activation-api', version: '1.2.0'
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.3.1' // 5.9.2
testImplementation group: 'org.jmock', name: 'jmock', version: '2.9.0' // 2.12.0
testImplementation group: 'org.jmock', name: 'jmock-junit4', version: '2.9.0' // 2.12.0
testImplementation 'junit:junit:4.12' // 4.3.1 org.junit.jupiter
// testImplementation 'org.junit.jupiter:junit-jupiter-api:5.7.0'
// testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.7.0'
}
def serializedEnginesPath = './src/main/resources/datafiles/thrustcurves/thrustcurves.ser'
def serializedEnginesPathDist = './build/resources/main/datafiles/thrustcurves/thrustcurves.ser'
// Executes the serialization of engines from ThrustCurve for a build.
tasks.register('serializeEngines') {
group = 'openrocket'
dependsOn serializeEnginesDelete
dependsOn serializeEnginesExecute
}
tasks.register('serializeEnginesDist') {
group = 'openrocket'
dependsOn serializeEnginesExecuteDist
}
// Deletes the serialize engine file if it exists.
tasks.register('serializeEnginesDelete', Delete) {
group = 'openrocket'
delete fileTree(serializedEnginesPath)
doFirst {
println "Starting serializeEnginesDelete..."
}
doLast {
println "...serializeEnginesDelete Completed"
}
}
// Executes the Java serialization program to fetch ThrustCurve rocket data and serialize it.
tasks.register('serializeEnginesExecute', JavaExec) {
group = 'openrocket'
dependsOn serializeEnginesDelete
workingDir new File(projectDir, 'build/tmp')
classpath = sourceSets.main.runtimeClasspath
mainClass.set('net.sf.openrocket.thrustcurve.SerializeThrustcurveMotors')
args '../../resources-src/datafiles/thrustcurves/', '../.' + serializedEnginesPath
doFirst {
println "Starting serializeEnginesExecute..."
// println "${serializedEnginesPath}"
}
doLast {
println "...serializeEnginesExecute Completed"
}
}
// Executes the Java serialization program to fetch ThrustCurve rocket data and serialize it.
// TODO: Shouldn't need a seperate task, but the args are not changing when dynamically updating
// the variable.
tasks.register('serializeEnginesExecuteDist', JavaExec) {
group = 'openrocket'
dependsOn serializeEnginesDelete
workingDir new File(projectDir, 'build/tmp')
classpath = sourceSets.main.runtimeClasspath
mainClass.set('net.sf.openrocket.thrustcurve.SerializeThrustcurveMotors')
args '../../resources-src/datafiles/thrustcurves/', '../.' + serializedEnginesPathDist
doFirst {
println "Starting serializeEnginesExecuteDist..."
}
doLast {
println "...serializeEnginesExecuteDist Completed"
}
}
// Validates that the serialize engines file exists.
tasks.register('serializeEnginesValidate') {
group = 'openrocket'
if (!project.file(serializedEnginesPath).exists()) {
def message = "The serialized engine file does not exist at the following location:\n${project.file(serializedEnginesPath)}.\n" +
"You will need to run the following from the command line in order to generate the serialized engine file:\n"
"% ./gradlew serializeEngines\n" +
"\n";
println message
throw new GradleException('Invalid serialized engine file.')
} else {
def message = "Serialized engine file found.\n\n";
println message
}
}
tasks.register('copyReadmeMain', Copy) {
doLast {
from('../') {
include 'ReleaseNotes.md'
}
into './src/main/resources'
}
}
processResources.dependsOn([copyReadmeMain])
processResources.dependsOn([serializeEnginesValidate])
// https://docs.gradle.org/7.4/userguide/cross_project_publications.html
tasks.register('testCoreArtifactsJar', Jar) {
archiveClassifier.set("tests")
from sourceSets.test.output
exclude "**/META-INF", "**/pix", "**/arch", "**/communication", "**/database", "**/file", "**/l10n", "**/models", "**/motor", "**/optimization", "**/plugin", "**/preset", "**/rocketcomponent", "**/simulation", "**/startup", "**/unit"
include "**/ServicesForTesting.class", "**/util/BaseTestCase.class"
}
// https://docs.gradle.org/7.4/userguide/cross_project_publications.html
configurations {
testArtifacts {
canBeConsumed = true
canBeResolved = false
extendsFrom testImplementation
}
}
// https://docs.gradle.org/7.4/userguide/cross_project_publications.html
artifacts {
testArtifacts(testCoreArtifactsJar)
}