gradle task to install all devices

This commit is contained in:
Alexander Nozik 2017-05-17 20:21:12 +03:00
parent a606777120
commit 4f0b12bbad
3 changed files with 47 additions and 3 deletions

View File

@ -7,3 +7,48 @@ dependencies {
compile group: 'org.controlsfx', name: 'controlsfx', version: '8.40.12'
}
task installAll(type: Copy) {
group "numass"
description "Install all control projects into the same directory"
def parser = new XmlParser()
subprojects { sub ->
dependsOn sub.getTasksByName("installDist", false).first()
String distDir = "${sub.buildDir}/install/${sub.name}"
from distDir
}
into "$buildDir/install/numass-control"
doLast {
def configRoot = new Node(null, "config");
subprojects { sub ->
//add device configuration file
def cfgFile = sub.file("src/main/resources/config/devices.xml")
if (cfgFile.exists()) {
println "Found device config file ${cfgFile}"
parser.parse(cfgFile).children().each {
configRoot.append(it as Node)
}
}
}
if (!configRoot.children().isEmpty()) {
File outFile = file("$buildDir/install/numass-control/config/devices.xml")
outFile.getParentFile().mkdirs();
outFile.createNewFile();
new XmlNodePrinter(outFile.newPrintWriter()).print(configRoot)
}
}
}
task distAll(dependsOn: installAll, type: Zip) {
group "numass"
description "Make a distribution of all control projects"
from "$buildDir/install/numass-control"
}

View File

@ -26,7 +26,7 @@ dependencies {
compile 'org.controlsfx:controlsfx:8.40.12'
compile "no.tornado:tornadofx:1.7.4"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-2"
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-3"
}
apply plugin: 'kotlin'

View File

@ -29,7 +29,6 @@ import java.time.Instant;
import java.util.Locale;
/**
*
* @author Alexander Nozik
*/
public class Talk {
@ -60,7 +59,7 @@ public class Talk {
while (!"exit".equals(nextString)) {
try {
Instant start = DateTimeUtils.now();
String answer = handler.sendAndWait(nextString + "\r", null, 1000);
String answer = handler.sendAndWait(nextString + "\r", 1000);
//String answer = controller.request(nextString);
System.out.printf("ANSWER (latency = %s): %s;%n", Duration.between(start, DateTimeUtils.now()), answer.trim());
} catch (PortException ex) {