Fix executable packaging

This commit is contained in:
Claude Brisson
2023-05-14 11:42:20 +02:00
parent 1bba7a11f1
commit 42ad283ee6
12 changed files with 174 additions and 62 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@ target
docker/data
.idea
docker/.env
pairgoth.properties

View File

@@ -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.

2
debug.bat Normal file
View File

@@ -0,0 +1,2 @@
mvn package
java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006 -jar application/target/pairgoth-engine.war

4
debug.sh Executable file
View File

@@ -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

View File

@@ -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

2
run.bat Normal file
View File

@@ -0,0 +1,2 @@
mvn package
java -jar application/target/pairgoth-engine.war

4
run.sh Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
mvn package
java -jar application/target/pairgoth-engine.war

View File

@@ -48,6 +48,52 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<executions>
<execution>
<id>enforce-properties-file-exists</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireFilesExist>
<message>Missing pairgoth.properties file</message>
<files>
<file>${project.parent.basedir}/pairgoth.properties</file>
</files>
</requireFilesExist>
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF</outputDirectory>
<resources>
<resource>
<directory>${basedir}/..</directory>
<include>pairgoth.properties</include>
<!-- <filtering>true</filtering> -->
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>

View File

@@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- Listeners -->
<!-- we're not using @WebListener annotations so that our manager is initialized *after* the webapp logger -->
<listener>
<listener-class>com.republicate.slf4j.impl.ServletContextLoggerListener</listener-class>
</listener>
<listener>
<listener-class>org.jeudego.pairgoth.web.WebappManager</listener-class>
</listener>
<!-- filters -->
<filter>
<filter-name>webapp-slf4j-logger-ip-tag-filter</filter-name>
<filter-class>com.republicate.slf4j.impl.IPTagFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<!-- filters mapping -->
<filter-mapping>
<filter-name>webapp-slf4j-logger-ip-tag-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- servlets -->
<servlet>
<servlet-name>api</servlet-name>
<servlet-class>org.jeudego.pairgoth.web.ApiServlet</servlet-class>
</servlet>
<!-- servlet mappings -->
<servlet-mapping>
<servlet-name>api</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<!-- context params -->
<context-param>
<param-name>webapp-slf4j-logger.format</param-name>
<param-value>%logger [%level] [%ip] %message @%file:%line:%column</param-value>
</context-param>
<context-param>
<param-name>webapp-slf4j-logger.level</param-name>
<param-value>${logger.level}</param-value>
</context-param>
<context-param>
<param-name>webapp-slf4j-logger.notification</param-name>
<param-value>${logger.notification}</param-value>
</context-param>
</web-app>

View File

@@ -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)

View File

@@ -1 +0,0 @@
../../../../target/pairgoth-1.0-SNAPSHOT/WEB-INF/web.xml

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- Listeners -->
<!-- we're not using @WebListener annotations so that our manager is initialized *after* the webapp logger -->
<listener>
<listener-class>com.republicate.slf4j.impl.ServletContextLoggerListener</listener-class>
</listener>
<listener>
<listener-class>org.jeudego.pairgoth.web.WebappManager</listener-class>
</listener>
<!-- filters -->
<filter>
<filter-name>webapp-slf4j-logger-ip-tag-filter</filter-name>
<filter-class>com.republicate.slf4j.impl.IPTagFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<!-- filters mapping -->
<filter-mapping>
<filter-name>webapp-slf4j-logger-ip-tag-filter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>FORWARD</dispatcher>
</filter-mapping>
<!-- servlets -->
<servlet>
<servlet-name>api</servlet-name>
<servlet-class>org.jeudego.pairgoth.web.ApiServlet</servlet-class>
</servlet>
<!-- servlet mappings -->
<servlet-mapping>
<servlet-name>api</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
<!-- context params -->
<context-param>
<param-name>webapp-slf4j-logger.format</param-name>
<param-value>%logger [%level] [%ip] %message @%file:%line:%column</param-value>
</context-param>
<context-param>
<param-name>webapp-slf4j-logger.level</param-name>
<param-value>trace</param-value>
<!-- CB TODO parametrize from webapp properties file
<param-value>${logger.level}</param-value>
-->
</context-param>
<!--
<context-param>
<param-name>webapp-slf4j-logger.notification</param-name>
<param-value>${logger.notification}</param-value>
</context-param>
-->
</web-app>

View File

@@ -1 +0,0 @@
../../../../target/pairgoth-1.0-SNAPSHOT/WEB-INF/webapp.properties