From 42ad283ee6d9f798b514f438705f893ee466da78 Mon Sep 17 00:00:00 2001 From: Claude Brisson Date: Sun, 14 May 2023 11:42:20 +0200 Subject: [PATCH] Fix executable packaging --- .gitignore | 1 + README.md | 46 ++++++++++++++ debug.bat | 2 + debug.sh | 4 ++ docker/run.sh | 14 +++-- run.bat | 2 + run.sh | 4 ++ webapp/pom.xml | 46 ++++++++++++++ webapp/src/main/config/web.xml | 55 ----------------- .../org/jeudego/pairgoth/web/WebappManager.kt | 1 - webapp/src/main/webapp/WEB-INF/web.xml | 60 ++++++++++++++++++- .../src/main/webapp/WEB-INF/webapp.properties | 1 - 12 files changed, 174 insertions(+), 62 deletions(-) create mode 100644 debug.bat create mode 100755 debug.sh create mode 100644 run.bat create mode 100755 run.sh delete mode 100644 webapp/src/main/config/web.xml mode change 120000 => 100644 webapp/src/main/webapp/WEB-INF/web.xml delete mode 120000 webapp/src/main/webapp/WEB-INF/webapp.properties diff --git a/.gitignore b/.gitignore index 5d04db0..8f13854 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ target docker/data .idea docker/.env +pairgoth.properties diff --git a/README.md b/README.md index b11592a..7fb9d84 100644 --- a/README.md +++ b/README.md @@ -1 +1,47 @@ # Pairgoth engine + +## Sources structure + +. +├── pairgoth.properties.example ............... Executable property file to instanciate +├── debug.sh .................................. Executable debug script, linux +├── debug.bat ................................. Executable debug script, windows +├── run.sh .................................... Executable run script, linux +├── run.bat ................................... Executable run script, windows +├── application ............................... Executable final packaging +├── bootstrap ................................. Executable entry point +├── container ................................. Web container +├── docker .................................... Docker packaging +│   ├── pairgoth.properties.example ........... Docker property file to instanciate +│   ├── run.sh ................................ Docker launch script +│   └── test.sh ............................... Docker test script +└── webapp .................................... Engine web application + └── src + ├── main + │   ├── kotlin ........................ Engine kotlin sources (the real meat is here!) + │   └── webapp ........................ Engine API webapp root + │   └── WEB-INF ................... Engine API webapp configuration + └── test + └── kotlin ........................ Engine webapp API unit tests + +## Building + + +### Executable + +You need maven installed. + +Copy and adapt `pairgoth.properties.example` towards `pairgoth.properties`. + +Just running `./run.sh` or `./run.bat` shoud build and run the engine . + +### Docker + +Under windows, please use the WSL. + +You need docker installed, and the current user being in the `docker` group. + +Copy and adapt `docker/pairgoth.properties.example` towards `docker/pairgoth.properties`. + +Just running `./run.sh` in the `docker` directory should build and run the engine. + diff --git a/debug.bat b/debug.bat new file mode 100644 index 0000000..48143fa --- /dev/null +++ b/debug.bat @@ -0,0 +1,2 @@ +mvn package +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006 -jar application/target/pairgoth-engine.war diff --git a/debug.sh b/debug.sh new file mode 100755 index 0000000..05770f8 --- /dev/null +++ b/debug.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +mvn package +java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006 -jar application/target/pairgoth-engine.war diff --git a/docker/run.sh b/docker/run.sh index cf6bffe..68ee258 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -1,9 +1,15 @@ #!/bin/bash -grep -r '^smtp\.host' webapp.properties | sed -r -e 's/smtp\.host/SMTP_HOST/' -e 's/ //g' > .env -grep -r '^smtp\.port' webapp.properties | sed -r -e 's/smtp\.port/SMTP_PORT/' -e 's/ //g' >> .env -grep -r '^smtp\.user' webapp.properties | sed -r -e 's/smtp\.user/SMTP_USER/' -e 's/ //g' >> .env -grep -r '^smtp\.password' webapp.properties | sed -r -e 's/smtp\.password/SMTP_PASSWORD/' -e 's/ //g' >> .env +if ! test -f pairgoth.properties +then + echo "Missing pairgoth.properties file" >&2 + exit 1 +fi + +grep -r '^smtp\.host' pairgoth.properties | sed -r -e 's/smtp\.host/SMTP_HOST/' -e 's/ //g' > .env +grep -r '^smtp\.port' pairgoth.properties | sed -r -e 's/smtp\.port/SMTP_PORT/' -e 's/ //g' >> .env +grep -r '^smtp\.user' pairgoth.properties | sed -r -e 's/smtp\.user/SMTP_USER/' -e 's/ //g' >> .env +grep -r '^smtp\.password' pairgoth.properties | sed -r -e 's/smtp\.password/SMTP_PASSWORD/' -e 's/ //g' >> .env mkdir -p data/jetty data/maven diff --git a/run.bat b/run.bat new file mode 100644 index 0000000..79190d1 --- /dev/null +++ b/run.bat @@ -0,0 +1,2 @@ +mvn package +java -jar application/target/pairgoth-engine.war diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..bc07847 --- /dev/null +++ b/run.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +mvn package +java -jar application/target/pairgoth-engine.war diff --git a/webapp/pom.xml b/webapp/pom.xml index 9b921be..f3597dc 100644 --- a/webapp/pom.xml +++ b/webapp/pom.xml @@ -48,6 +48,52 @@ + + org.apache.maven.plugins + maven-enforcer-plugin + + + enforce-properties-file-exists + + enforce + + + + + Missing pairgoth.properties file + + ${project.parent.basedir}/pairgoth.properties + + + + true + + + + + + org.apache.maven.plugins + maven-resources-plugin + + + copy-resources + process-resources + + copy-resources + + + ${project.build.directory}/${project.build.finalName}/WEB-INF + + + ${basedir}/.. + pairgoth.properties + + + + + + + diff --git a/webapp/src/main/config/web.xml b/webapp/src/main/config/web.xml deleted file mode 100644 index fa11af6..0000000 --- a/webapp/src/main/config/web.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - com.republicate.slf4j.impl.ServletContextLoggerListener - - - org.jeudego.pairgoth.web.WebappManager - - - - - webapp-slf4j-logger-ip-tag-filter - com.republicate.slf4j.impl.IPTagFilter - true - - - - - webapp-slf4j-logger-ip-tag-filter - /* - REQUEST - FORWARD - - - - - api - org.jeudego.pairgoth.web.ApiServlet - - - - - api - /api/* - - - - - webapp-slf4j-logger.format - %logger [%level] [%ip] %message @%file:%line:%column - - - webapp-slf4j-logger.level - ${logger.level} - - - webapp-slf4j-logger.notification - ${logger.notification} - - - diff --git a/webapp/src/main/kotlin/org/jeudego/pairgoth/web/WebappManager.kt b/webapp/src/main/kotlin/org/jeudego/pairgoth/web/WebappManager.kt index 8e3d337..7ca2d7f 100644 --- a/webapp/src/main/kotlin/org/jeudego/pairgoth/web/WebappManager.kt +++ b/webapp/src/main/kotlin/org/jeudego/pairgoth/web/WebappManager.kt @@ -50,7 +50,6 @@ class WebappManager : ServletContextListener, ServletContextAttributeListener, H /* ServletContextListener interface */ override fun contextInitialized(sce: ServletContextEvent) { - if (1==1) throw IllegalAccessError("sgdfgsdfg"); context = sce.servletContext logger.info("---------- Starting Web Application ----------") context.setAttribute("manager", this) diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml deleted file mode 120000 index 98643eb..0000000 --- a/webapp/src/main/webapp/WEB-INF/web.xml +++ /dev/null @@ -1 +0,0 @@ -../../../../target/pairgoth-1.0-SNAPSHOT/WEB-INF/web.xml \ No newline at end of file diff --git a/webapp/src/main/webapp/WEB-INF/web.xml b/webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 0000000..b501415 --- /dev/null +++ b/webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,59 @@ + + + + + + com.republicate.slf4j.impl.ServletContextLoggerListener + + + org.jeudego.pairgoth.web.WebappManager + + + + + webapp-slf4j-logger-ip-tag-filter + com.republicate.slf4j.impl.IPTagFilter + true + + + + + webapp-slf4j-logger-ip-tag-filter + /* + REQUEST + FORWARD + + + + + api + org.jeudego.pairgoth.web.ApiServlet + + + + + api + /api/* + + + + + webapp-slf4j-logger.format + %logger [%level] [%ip] %message @%file:%line:%column + + + webapp-slf4j-logger.level + trace + + + + diff --git a/webapp/src/main/webapp/WEB-INF/webapp.properties b/webapp/src/main/webapp/WEB-INF/webapp.properties deleted file mode 120000 index c04dfb6..0000000 --- a/webapp/src/main/webapp/WEB-INF/webapp.properties +++ /dev/null @@ -1 +0,0 @@ -../../../../target/pairgoth-1.0-SNAPSHOT/WEB-INF/webapp.properties \ No newline at end of file