GitLab update scheduled for Friday, October 22th between 08:15 and 08:45 CEST. If unpleasant, please contact René or Martin.

Commit 6e2953a3 authored by René Schöne's avatar René Schöne
Browse files

towards releasing 0.3.1

- fix bug in getSecondMqttHost
- remove dependency to log4j
- use java.util.logging in Compiler
- add flag --experimental-jastadd-329 to enable behaviour using an unpublished JastAdd version with solution for issue 329
parent d54ce223
Pipeline #9830 failed with stages
in 12 minutes and 11 seconds
......@@ -27,9 +27,6 @@ repositories {
dependencies {
implementation project(':relast-preprocessor')
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: "${log4j_version}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: "${log4j_version}"
implementation group: 'org.apache.logging.log4j', name: 'log4j-jul', version: "${log4j_version}"
implementation group: 'com.github.spullara.mustache.java', name: 'compiler', version: "${mustache_java_version}"
// runtimeOnly group: 'org.jastadd', name: 'jastadd', version: '2.3.5'
runtimeOnly fileTree(include: ['jastadd2.jar'], dir: '../libs')
......@@ -68,14 +65,12 @@ idea.module.generatedSourceDirs += genSrc
jar {
manifest {
attributes "Main-Class": 'org.jastadd.ragconnect.compiler.Compiler'
// Log4J + Java 11 compatibility, see https://stackoverflow.com/q/53049346/2493208
attributes "Multi-Release": true
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
archiveBaseName = 'ragconnect'
}
......
......@@ -6,4 +6,5 @@ aspect Configuration {
public static boolean ASTNode.usesMqtt;
public static boolean ASTNode.usesRest;
public static boolean ASTNode.incrementalOptionActive;
public static boolean ASTNode.experimentalJastAdd329;
}
......@@ -3,11 +3,11 @@ package org.jastadd.ragconnect.compiler;
import beaver.Parser;
import org.jastadd.option.BooleanOption;
import org.jastadd.option.ValueOption;
import org.jastadd.relast.compiler.AbstractCompiler;
import org.jastadd.relast.compiler.CompilerException;
import org.jastadd.ragconnect.ast.*;
import org.jastadd.ragconnect.parser.RagConnectParser;
import org.jastadd.ragconnect.scanner.RagConnectScanner;
import org.jastadd.relast.compiler.AbstractCompiler;
import org.jastadd.relast.compiler.CompilerException;
import java.io.*;
import java.nio.file.Files;
......@@ -15,6 +15,8 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Compiler extends AbstractCompiler {
......@@ -26,10 +28,13 @@ public class Compiler extends AbstractCompiler {
private BooleanOption optionLogReads;
private BooleanOption optionLogWrites;
private BooleanOption optionLogIncremental;
private BooleanOption optionExperimentalJastAdd329;
private static final String OPTION_PROTOCOL_MQTT = "mqtt";
private static final String OPTION_PROTOCOL_REST = "rest";
private final static Logger LOGGER = Logger.getLogger(Compiler.class.getName());
public Compiler() {
super("ragconnect", true);
}
......@@ -44,8 +49,11 @@ public class Compiler extends AbstractCompiler {
getConfiguration().printHelp(System.out);
return 0;
}
if (optionVerbose.value()) {
LOGGER.setLevel(Level.FINE);
}
printMessage("Running RagConnect " + readVersion());
LOGGER.info(() -> "Running RagConnect " + readVersion());
if (!getConfiguration().outputDir().exists()) {
try {
......@@ -62,9 +70,9 @@ public class Compiler extends AbstractCompiler {
RagConnect ragConnect = parseProgram(getConfiguration().getFiles());
if (!ragConnect.errors().isEmpty()) {
System.err.println("Errors:");
LOGGER.severe("Errors:");
for (ErrorMessage e : ragConnect.errors()) {
System.err.println(e);
LOGGER.severe(e.toString());
}
System.exit(1);
}
......@@ -77,7 +85,7 @@ public class Compiler extends AbstractCompiler {
return 0;
}
printMessage("Writing output files");
LOGGER.fine("Writing output files");
final List<String> handlers = new ArrayList<>();
if (ASTNode.usesMqtt) {
handlers.add("MqttHandler.jadd");
......@@ -108,12 +116,11 @@ public class Compiler extends AbstractCompiler {
}
public static void main(String[] args) {
System.setProperty("java.util.logging.manager", "org.apache.logging.log4j.jul.LogManager");
System.setProperty("mustache.debug", "true");
try {
new Compiler().run(args);
} catch (CompilerException e) {
e.printStackTrace();
LOGGER.log(Level.SEVERE, e.getMessage(), e);
System.exit(1);
}
}
......@@ -138,12 +145,6 @@ public class Compiler extends AbstractCompiler {
}
}
private void printMessage(String message) {
if (optionVerbose.value()) {
System.out.println(message);
}
}
private void writeToFile(Path path, String str) throws CompilerException {
try (BufferedWriter writer = Files.newBufferedWriter(path)) {
writer.append(str);
......@@ -179,6 +180,9 @@ public class Compiler extends AbstractCompiler {
optionLogIncremental = addOption(
new BooleanOption("logIncremental", "Enable logging for observer in incremental dependency tracking.")
.defaultValue(false));
optionExperimentalJastAdd329 = addOption(
new BooleanOption("experimental-jastadd-329", "Use trace events INC_FLUSH_START and INC_FLUSH_END (JastAdd issue #329).")
.defaultValue(false));
}
private RagConnect parseProgram(Collection<String> files) throws CompilerException {
......@@ -214,10 +218,10 @@ public class Compiler extends AbstractCompiler {
}
}
if (!atLeastOneGrammar) {
System.err.println("No grammar file specified! (*.ast, *.relast)");
LOGGER.severe(() -> "No grammar file specified! (*.ast, *.relast)");
}
if (!atLeastOneRagConnect) {
System.err.println("No ragconnect file specified! (*.connect, *.ragconnect)");
LOGGER.severe(() -> "No ragconnect file specified! (*.connect, *.ragconnect)");
}
if (!atLeastOneGrammar && !atLeastOneRagConnect) {
System.exit(1);
......@@ -231,10 +235,11 @@ public class Compiler extends AbstractCompiler {
ASTNode.loggingEnabledForReads = optionLogReads.value();
ASTNode.loggingEnabledForWrites = optionLogWrites.value();
ASTNode.loggingEnabledForIncremental = optionLogIncremental.value();
ASTNode.experimentalJastAdd329 = optionExperimentalJastAdd329.value();
// reuse "--incremental" option of JastAdd
ASTNode.incrementalOptionActive = getConfiguration().incremental() && getConfiguration().traceFlush();
printMessage("ASTNode.incrementalOptionActive = " + ASTNode.incrementalOptionActive);
LOGGER.fine(() -> "ASTNode.incrementalOptionActive = " + ASTNode.incrementalOptionActive);
ASTNode.usesMqtt = optionProtocols.hasValue(OPTION_PROTOCOL_MQTT);
ASTNode.usesRest = optionProtocols.hasValue(OPTION_PROTOCOL_REST);
......@@ -247,7 +252,7 @@ public class Compiler extends AbstractCompiler {
RagConnectParser parser = new RagConnectParser();
GrammarFile grammarFile = (GrammarFile) parser.parse(scanner);
if (optionVerbose.value()) {
grammarFile.dumpTree(System.out);
LOGGER.fine(grammarFile::dumpTree);
}
program.addGrammarFile(grammarFile);
grammarFile.setFileName(toBaseName(filename));
......
package org.jastadd.ragconnect.compiler;
import org.jastadd.ragconnect.ast.Document;
import org.jastadd.ragconnect.ast.ListElement;
import org.jastadd.ragconnect.ast.MappingElement;
/**
* Testing Ros2Rag without parser.
*
* @author rschoene - Initial contribution
*/
public class SimpleMain {
private static void printManualYAML() {
Document doc = new Document();
MappingElement root = new MappingElement();
MappingElement firstLevel = new MappingElement();
firstLevel.put("server", "tcp://localhost:1883");
firstLevel.put("robot_speed_factor", ".7");
MappingElement theTopics = new MappingElement();
theTopics.put("robotConfig", "robotconfig");
theTopics.put("trajectory", "trajectory");
theTopics.put("nextStep", "ros2rag/nextStep");
firstLevel.put("topics", theTopics);
firstLevel.put("zone_size", "0.5");
ListElement theZones = new ListElement();
theZones.add("1 1");
theZones.add("0 1");
theZones.add("-1 1");
firstLevel.put("zones", theZones);
MappingElement pandaParts = new MappingElement();
MappingElement thePanda = new MappingElement();
thePanda.put("Link0", "panda_link0");
thePanda.put("Link1", "panda_link1");
thePanda.put("Link2", "panda_link2");
thePanda.put("Link3", "panda_link3");
thePanda.put("Link4", "panda_link4");
thePanda.put("Link5", "panda_link5");
thePanda.put("Link6", "panda_link6");
thePanda.put("RightFinger", "panda_rightfinger");
thePanda.put("LeftFinger", "panda_leftfinger");
pandaParts.put("panda", thePanda);
firstLevel.put("parts", pandaParts);
MappingElement endEffectorParts = new MappingElement();
MappingElement endEffector = new MappingElement();
endEffector.put("EndEffector", "panda_hand");
endEffectorParts.put("panda", endEffector);
firstLevel.put("end_effectors", endEffectorParts);
ListElement theGoalPoses = new ListElement();
theGoalPoses.add(makePose("0.4 0.4 0.3"));
theGoalPoses.add(makePose("-0.4 0.4 0.3"));
theGoalPoses.add(makePose("-0.4 -0.4 0.3"));
theGoalPoses.add(makePose("0.4 0.4 0.3"));
theGoalPoses.add(makePose("-0.4 0.4 0.3"));
theGoalPoses.add(makePose("0.4 0.4 0.3"));
firstLevel.put("goal_poses", theGoalPoses);
root.put("panda_mqtt_connector", firstLevel);
doc.setRootElement(root);
System.out.println(doc.prettyPrint());
}
private static MappingElement makePose(String position) {
MappingElement goalPose = new MappingElement();
goalPose.put("position", position);
goalPose.put("orientation", "1 1 0 0");
goalPose.put("work", "20000");
return goalPose;
}
public static void main(String[] args) {
printManualYAML();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="INFO">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
......@@ -68,6 +68,7 @@ aspect RagConnectObserver {
}
}
{{#experimentalJastAdd329}}
class RagConnectObserverStartEntry {
final ASTNode node;
final String attributeString;
......@@ -78,12 +79,16 @@ aspect RagConnectObserver {
this.flushIncToken = flushIncToken;
}
}
{{/experimentalJastAdd329}}
ASTState.Trace.Receiver oldReceiver;
java.util.List<RagConnectObserverEntry> observedNodes = new java.util.ArrayList<>();
{{#experimentalJastAdd329}}
java.util.Set<RagConnectObserverEntry> entryQueue = new java.util.HashSet<>();
RagConnectObserverStartEntry startEntry = null;
{{/experimentalJastAdd329}}
RagConnectObserver(ASTNode node) {
// set the receiver. potentially dangerous because overriding existing receiver!
......@@ -103,6 +108,7 @@ aspect RagConnectObserver {
@Override
public void accept(ASTState.Trace.Event event, ASTNode node, String attribute, Object params, Object value) {
oldReceiver.accept(event, node, attribute, params, value);
{{#experimentalJastAdd329}}
// react to INC_FLUSH_START and remember entry
if (event == ASTState.Trace.Event.INC_FLUSH_START && startEntry == null) {
{{#loggingEnabledForIncremental}}
......@@ -130,6 +136,7 @@ aspect RagConnectObserver {
return;
}
{{/experimentalJastAdd329}}
// ignore all other events but INC_FLUSH_ATTR
if (event != ASTState.Trace.Event.INC_FLUSH_ATTR) {
return;
......@@ -145,7 +152,12 @@ aspect RagConnectObserver {
{{#loggingEnabledForIncremental}}
System.out.println("** observer hit: " + entry.node + " on " + entry.attributeString);
{{/loggingEnabledForIncremental}}
{{#experimentalJastAdd329}}
entryQueue.add(entry);
{{/experimentalJastAdd329}}
{{^experimentalJastAdd329}}
entry.attributeCall.run();
{{/experimentalJastAdd329}}
}
}
}
......
......@@ -36,8 +36,8 @@ repositories {
dependencies {
implementation project(':ragconnect.base')
// runtimeOnly group: 'org.jastadd', name: 'jastadd', version: '2.3.5'
runtimeOnly fileTree(include: ['jastadd2.jar'], dir: '../libs')
runtimeOnly group: 'org.jastadd', name: 'jastadd', version: '2.3.5'
// runtimeOnly fileTree(include: ['jastadd2.jar'], dir: '../libs')
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: '5.4.0'
testRuntimeOnly group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: '5.4.0'
......
......@@ -2,7 +2,6 @@ package org.jastadd.ragconnect.tests;
import defaultOnlyRead.ast.A;
import defaultOnlyRead.ast.BoxedTypes;
import defaultOnlyRead.ast.MqttHandler;
import defaultOnlyRead.ast.NativeTypes;
import org.junit.jupiter.api.Test;
......@@ -10,9 +9,9 @@ import java.io.IOException;
import java.nio.file.Paths;
import java.util.concurrent.TimeUnit;
import static org.jastadd.ragconnect.tests.TestUtils.*;
import static org.jastadd.ragconnect.tests.TestUtils.mqttUri;
import static org.jastadd.ragconnect.tests.TestUtils.testJaddContainReferenceToJackson;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Test case "defaultOnlyRead".
......
......@@ -31,8 +31,8 @@ public class TestUtils {
public static String getSecondMqttHost() {
if (System.getenv("GITLAB_CI") != null) {
// we are in the CI, so use "mqtt_different_port" as host
return "mqtt_different_port";
// we are in the CI, so use "mqtt_different_port" as host and 55883 as port
return "mqtt_different_port:55883";
} {
// else no second local mqtt broker
return null;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment