diff --git a/.gitignore b/.gitignore index 50512b5..2802541 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ hs_err_pid* target/ nohup.out + +.idea diff --git a/Dockerfile b/Dockerfile index 9465820..49598a0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,14 @@ # syntax=docker/dockerfile:1 +FROM maven:eclipse-temurin AS builder + +WORKDIR /tmp + +COPY src /tmp/src +COPY resources /tmp/resources +COPY static /tmp/static +COPY pom.xml /tmp/pom.xml + +RUN mvn -B -f /tmp/pom.xml clean package FROM ubuntu:latest @@ -17,12 +27,10 @@ RUN apt install -y ghostscript pdf2svg texlive-extra-utils RUN apt install -y openjdk-11-jre -COPY src /app/src COPY resources /app/resources COPY static /app/static -COPY pom.xml /app/pom.xml # Assumes mvn install was run prior to build Dockerfile -ADD target/antlr4-lab-$LAB_VERSION-complete.jar antlr4-lab-$LAB_VERSION-complete.jar -ENTRYPOINT java -jar /app/antlr4-lab-$LAB_VERSION-complete.jar +COPY --from=builder /tmp/target/antlr4-lab-*-complete.jar antlr4-lab-complete.jar +ENTRYPOINT ["java", "-jar", "/app/antlr4-lab-complete.jar"] EXPOSE 80 diff --git a/README.md b/README.md index 19c7ca0..df48e09 100644 --- a/README.md +++ b/README.md @@ -52,24 +52,16 @@ If you are running the server locally on your box, visit [http://localhost/index ### Docker -I created a [Dockerfile](Dockerfile), although I'm not sure how useful it will be to people. This might be useful for deploying in the cloud later. - -Here's how to build the docker file: - +Docker builds both jar and the image: ```bash -cd antlr4-lab -mvn clean package # has to be built first as docker copies in the jar -docker build --tag antlr4-lab-docker . +docker build -t antlr4-lab . ``` -and here's how to use the docker to launch: - +To run docker image: ```bash -docker run -p80:80 --rm antlr4-lab-docker +docker run -p 8080:80 antlr4-lab ``` -@kaby76 reports the following: Seems to work fine. But I had to do some things to get it to work on Windows/WSL2. - In Windows: Install Docker Desktop In WSL2/Ubuntu: diff --git a/pom.xml b/pom.xml index 9f12d00..8a92e48 100644 --- a/pom.xml +++ b/pom.xml @@ -1,10 +1,5 @@ 4.0.0 - - org.sonatype.oss - oss-parent - 9 - org.antlr antlr4-lab @@ -47,55 +42,35 @@ antlr4 4.13.1 - - org.antlr - antlr-runtime - 3.5.3 - - - org.antlr - ST4 - 4.3.4 - - - org.eclipse.jetty - jetty-server - 11.0.11 - org.eclipse.jetty jetty-webapp - 11.0.11 + 11.0.18 - org.slf4j - slf4j-api - 1.7.36 - - - org.slf4j - slf4j-jdk14 - 1.8.0-beta4 + jakarta.servlet + jakarta.servlet-api + 6.0.0 ch.qos.logback - logback-core - 1.2.11 + logback-classic + 1.4.11 - ch.qos.logback - logback-classic - 1.2.6 + org.slf4j + slf4j-api + 2.0.9 us.parr parrtlib - 0.5-SNAPSHOT + 0.4 com.google.code.gson gson - 2.10 + 2.10.1 diff --git a/resources/logback.xml b/resources/logback.xml index 1e76bef..f5f8373 100644 --- a/resources/logback.xml +++ b/resources/logback.xml @@ -16,9 +16,10 @@ + - \ No newline at end of file + diff --git a/src/org/antlr/v4/server/GrammarProcessor.java b/src/org/antlr/v4/server/GrammarProcessor.java index 1261357..6e13d57 100644 --- a/src/org/antlr/v4/server/GrammarProcessor.java +++ b/src/org/antlr/v4/server/GrammarProcessor.java @@ -13,11 +13,11 @@ import org.antlr.v4.runtime.tree.ParseTree; import org.antlr.v4.runtime.tree.Tree; import org.antlr.v4.tool.*; +import us.parr.lib.ParrtSys; import static org.antlr.v4.gui.Interpreter.profilerColumnNames; import static org.antlr.v4.server.ANTLRHttpServer.IMAGES_DIR; import static org.antlr.v4.server.ANTLRHttpServer.ParseServlet.LOGGER; -import static us.parr.lib.ParrtSys.execInDir; import java.io.*; import java.nio.file.Files; @@ -259,6 +259,10 @@ public static String toSVG(Tree t, List ruleNames) throws IOException { return svg; } + private static String[] execInDir(String imagesDir, String program, String... args) { + return ParrtSys.exec("env --chdir=" + imagesDir + " " + program + " " + String.join(" ", args)); + } + public static final int nodeCount(Tree t) { if (t == null) { return 0;