Jetty embedding revisited

This commit is contained in:
Claude Brisson
2023-05-12 14:21:41 +02:00
parent adca33ee26
commit a28f623eee
45 changed files with 911 additions and 470 deletions

84
application/pom.xml Normal file
View File

@@ -0,0 +1,84 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jeudego.pairgoth</groupId>
<artifactId>engine-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>application</artifactId>
<packaging>pom</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<serverManifestDirectory>${project.build.directory}/servermanifest</serverManifestDirectory>
</properties>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>webapp</artifactId>
<version>${project.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>bootstrap</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>container</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<finalName>pairgoth-engine</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>use-server-manifest</id>
<phase>prepare-package</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>bootstrap</artifactId>
<version>${project.version}</version>
<outputDirectory>${serverManifestDirectory}</outputDirectory>
<includes>META-INF/MANIFEST.MF</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>build-livewar</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/livewar.xml</descriptor>
</descriptors>
<archive>
<manifestFile>${serverManifestDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,29 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>live-war</id>
<baseDirectory>/</baseDirectory>
<formats>
<format>war</format>
</formats>
<dependencySets>
<dependencySet>
<outputDirectory>/WEB-INF/jetty-server/</outputDirectory>
<unpack>true</unpack>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<include>${project.groupId}:container</include>
</includes>
</dependencySet>
<dependencySet>
<outputDirectory>/</outputDirectory>
<unpack>true</unpack>
<useTransitiveDependencies>false</useTransitiveDependencies>
<includes>
<include>${project.groupId}:webapp</include>
<include>${project.groupId}:bootstrap</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>

31
bootstrap/pom.xml Normal file
View File

@@ -0,0 +1,31 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jeudego.pairgoth</groupId>
<artifactId>engine-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>bootstrap</artifactId>
<packaging>jar</packaging>
<description>Simple Bootstrap for the Server UberJar (when packaged in a WAR)</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
<mainClass>jetty.bootstrap.JettyBootstrap</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,55 @@
//
// ========================================================================
// Copyright (c) Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package jetty.bootstrap;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.net.URL;
public class JettyBootstrap
{
public static void main(String[] args)
{
try
{
URL warLocation = JettyBootstrap.class.getProtectionDomain().getCodeSource().getLocation();
if (warLocation == null)
{
throw new IOException("JettyBootstrap not discoverable");
}
LiveWarClassLoader clWar = new LiveWarClassLoader(warLocation);
System.err.println("Using ClassLoader: " + clWar);
Thread.currentThread().setContextClassLoader(clWar);
File warFile = new File(warLocation.toURI());
System.setProperty("org.eclipse.jetty.livewar.LOCATION",warFile.toPath().toRealPath().toString());
Class<?> mainClass = Class.forName("org.jeudego.pairgoth.container.ServerMain",false,clWar);
Method mainMethod = mainClass.getMethod("main",args.getClass());
mainMethod.invoke(mainClass,new Object[] { args });
}
catch (Throwable t)
{
t.printStackTrace(System.err);
System.exit(-1);
}
}
}

View File

@@ -0,0 +1,171 @@
//
// ========================================================================
// Copyright (c) Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package jetty.bootstrap;
import java.io.ByteArrayOutputStream;
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
public class LiveWarClassLoader extends ClassLoader implements Closeable
{
private static final String ID = LiveWarClassLoader.class.getSimpleName();
private static final boolean DEBUG = Boolean.getBoolean("jetty.bootstrap.debug");
private static final String CLASSES_BASE = "WEB-INF/jetty-server/";
private final URI warFileUri;
private JarFile warFile;
public LiveWarClassLoader(URL warFileUrl) throws URISyntaxException, IOException
{
this.warFileUri = warFileUrl.toURI();
this.warFile = new JarFile(new File(warFileUri));
}
public void close() throws IOException
{
warFile.close();
}
private void debug(String format, Object... args)
{
if (DEBUG)
{
System.err.printf('[' + ID + "] " + format + "%n",args);
}
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException
{
debug("findClass: %s",name);
String path = name.replace('.','/').concat(".class");
ZipEntry entry = findEntry(path);
if (entry != null)
{
try
{
return loadClass(name,entry);
}
catch (IOException e)
{
throw new ClassNotFoundException(name,e);
}
}
else
{
throw new ClassNotFoundException(name);
}
}
private ZipEntry findEntry(String name)
{
StringBuilder path = new StringBuilder();
path.append(CLASSES_BASE);
if (name.charAt(0) == '/')
{
path.append(name.substring(1));
}
else
{
path.append(name);
}
ZipEntry entry = warFile.getEntry(path.toString());
debug("findEntry(%s) %s => %s",name,path,entry);
return entry;
}
@Override
protected URL findResource(String name)
{
debug("findResource: %s",name);
ZipEntry entry = findEntry(name);
if (entry != null)
{
try
{
return URI.create("jar:" + this.warFileUri.toASCIIString() + "!/" + entry.getName()).toURL();
}
catch (MalformedURLException e)
{
e.printStackTrace(System.err);
return null;
}
}
return null;
}
@Override
protected Enumeration<URL> findResources(String name) throws IOException
{
debug("findResources: %s",name);
List<URL> urls = new ArrayList<>();
URL self = findResource(name);
if (self != null)
{
urls.add(self);
}
if (getParent() != null)
{
Enumeration<URL> parent = getParent().getResources(name);
while (parent.hasMoreElements())
{
urls.add(parent.nextElement());
}
}
return Collections.enumeration(urls);
}
private Class<?> loadClass(String name, ZipEntry entry) throws IOException
{
try (InputStream in = warFile.getInputStream(entry); ByteArrayOutputStream out = new ByteArrayOutputStream())
{
int len = 0;
int bufferSize = 4096;
byte[] buffer = new byte[bufferSize];
while (true)
{
len = in.read(buffer,0,bufferSize);
if (len < 0)
break;
out.write(buffer,0,len);
}
byte[] classBytes = out.toByteArray();
return defineClass(name,classBytes,0,classBytes.length);
}
}
@Override
public String toString()
{
return String.format("%s[%s]",this.getClass().getName(),this.warFileUri);
}
}

74
container/pom.xml Normal file
View File

@@ -0,0 +1,74 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jeudego.pairgoth</groupId>
<artifactId>engine-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>container</artifactId>
<packaging>jar</packaging>
<description>Creates a UberJar consisting of all classes needed to start Jetty</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-webapp</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-annotations</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-javax-server</artifactId>
<version>${jetty.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<id>rebuild-war</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>META-INF/VERSION.txt</exclude>
</excludes>
</filter>
</filters>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,108 @@
//
// ========================================================================
// Copyright (c) Mort Bay Consulting Pty Ltd and others.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.jeudego.pairgoth.container;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.util.resource.PathResource;
import org.eclipse.jetty.webapp.WebAppContext;
public class ServerMain
{
enum OperationalMode
{
DEV,
PROD
}
private Path basePath;
public static void main(String[] args)
{
try
{
new ServerMain().run();
}
catch (Throwable t)
{
t.printStackTrace();
}
}
private void run() throws Throwable
{
Server server = new Server(8080);
WebAppContext context = new WebAppContext();
context.setContextPath("/");
switch (getOperationalMode())
{
case PROD:
// Configure as WAR
context.setWar(basePath.toString());
break;
case DEV:
// Configuring from Development Base
context.setBaseResource(new PathResource(basePath.resolve("src/main/webapp")));
// Add webapp compiled classes & resources (copied into place from src/main/resources)
Path classesPath = basePath.resolve("target/webapp/WEB-INF/classes");
context.setExtraClasspath(classesPath.toAbsolutePath().toString());
server.setDumpAfterStart(true);
break;
default:
throw new FileNotFoundException("Unable to configure WebAppContext base resource undefined");
}
server.setHandler(context);
server.start();
server.join();
}
private OperationalMode getOperationalMode() throws IOException
{
// Property set by jetty.bootstrap.JettyBootstrap
String warLocation = System.getProperty("org.eclipse.jetty.livewar.LOCATION");
if (warLocation != null)
{
Path warPath = new File(warLocation).toPath().toRealPath();
if (Files.exists(warPath) && Files.isRegularFile(warPath))
{
this.basePath = warPath;
return OperationalMode.PROD;
}
}
// We are in development mode, likely building and testing from an IDE.
Path devPath = new File("../webapp").toPath().toRealPath();
if (Files.exists(devPath) && Files.isDirectory(devPath))
{
this.basePath = devPath;
return OperationalMode.DEV;
}
return null;
}
}

View File

@@ -0,0 +1,8 @@
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
org.eclipse.jetty.LEVEL=INFO
# Squelch noisy logging
org.eclipse.jetty.websocket.jsr356.JsrBasicRemote.LEVEL=WARN
# org.eclipse.jetty.annotations.LEVEL=DEBUG
# org.eclipse.jetty.websocket.LEVEL=DEBUG

565
pom.xml
View File

@@ -1,474 +1,151 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.jeudego</groupId> <groupId>org.jeudego.pairgoth</groupId>
<artifactId>pairgoth</artifactId> <artifactId>engine-parent</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<packaging>war</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>PairGoth pairing system</description>
<url>TODO</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <maven.compiler.source>11</maven.compiler.source>
<junit.version>4.13.2</junit.version> <maven.compiler.target>11</maven.compiler.target>
<slf4j.version>1.7.36</slf4j.version>
<servlet.version>3.1.0</servlet.version> <maven.assembly.plugin.version>3.5.0</maven.assembly.plugin.version>
<kotlin.version>1.8.21</kotlin.version> <maven.clean.plugin.version>3.2.0</maven.clean.plugin.version>
<kotlin.code.style>official</kotlin.code.style> <maven.compiler.plugin.version>3.11.0</maven.compiler.plugin.version>
<kotlin.compiler.jvmTarget>10</kotlin.compiler.jvmTarget> <maven.dependency.plugin.version>3.5.0</maven.dependency.plugin.version>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental> <maven.deploy.plugin.version>3.1.1</maven.deploy.plugin.version>
<pac4j.version>5.7.1</pac4j.version> <maven.enforcer.plugin.version>3.3.0</maven.enforcer.plugin.version>
<jetty.version>10.0.12</jetty.version> <maven.install.plugin.version>3.1.1</maven.install.plugin.version>
<jetty.files>${project.build.directory}/${project.build.finalName}/WEB-INF/jetty</jetty.files> <maven.jar.plugin.version>3.3.0</maven.jar.plugin.version>
<jetty.port>8080</jetty.port> <maven.javadoc.plugin.version>3.5.0</maven.javadoc.plugin.version>
<maven.resources.plugin.version>3.3.1</maven.resources.plugin.version>
<maven.shade.plugin.version>3.4.1</maven.shade.plugin.version>
<maven.source.plugin.version>3.2.1</maven.source.plugin.version>
<maven.surefire.plugin.version>3.0.0</maven.surefire.plugin.version>
<maven.war.plugin.version>3.3.2</maven.war.plugin.version>
<license.plugin.version>4.2</license.plugin.version>
<servlet.api.version>4.0.4</servlet.api.version>
<websocket.api.version>1.1.2</websocket.api.version>
<jetty.version>10.0.15</jetty.version>
<slf4j.version>2.0.0-alpha3</slf4j.version>
</properties> </properties>
<profiles>
<profile> <modules>
<id>pairgoth</id> <module>webapp</module>
<activation> <module>container</module>
<activeByDefault>true</activeByDefault> <module>bootstrap</module>
</activation> <module>application</module>
<properties> </modules>
<webapp.properties>/var/lib/pairgoth/pairgoth.properties</webapp.properties>
</properties>
</profile>
</profiles>
<build> <build>
<defaultGoal>package</defaultGoal> <pluginManagement>
<sourceDirectory>src/main/kotlin</sourceDirectory> <plugins>
<testSourceDirectory>src/test/kotlin</testSourceDirectory> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven.assembly.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven.clean.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.dependency.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>${maven.deploy.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>${maven.enforcer.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven.install.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>${maven.javadoc.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>${maven.resources.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven.source.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>${maven.war.plugin.version}</version>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${license.plugin.version}</version>
</plugin>
</plugins>
</pluginManagement>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId> <artifactId>maven-enforcer-plugin</artifactId>
<version>3.1.0</version>
<executions> <executions>
<execution> <execution>
<id>enforce-maven</id> <id>enforce-java</id>
<goals> <goals>
<goal>enforce</goal> <goal>enforce</goal>
</goals> </goals>
<configuration> <configuration>
<rules> <rules>
<requireMavenVersion> <requireMavenVersion>
<version>3.6.3</version> <version>[3.0.0,)</version>
</requireMavenVersion> </requireMavenVersion>
<requireJavaVersion>
<version>[11,)</version>
<message>[ERROR] OLD JDK [${java.version}] in use. This project requires JDK 11 or newer</message>
</requireJavaVersion>
</rules> </rules>
</configuration> </configuration>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M7</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.0.0-M7</version>
<executions>
<execution>
<id>run-tests</id>
<phase>integration-test</phase>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/Test*</include>
</includes>
<redirectTestOutputToFile>false</redirectTestOutputToFile>
<environmentVariables>
<EASYEDI_HOME>${project.build.testOutputDirectory}</EASYEDI_HOME>
<ENVIRONMENT>dev</ENVIRONMENT>
</environmentVariables>
<systemProperties>
<property>
<name>project.version</name>
<value>${project.version}</value>
</property>
<property>
<name>project.dir</name>
<value>${project.basedir}</value>
</property>
<property>
<name>build.dir</name>
<value>${project.build.directory}</value>
</property>
<property>
<name>test.resources.dir</name>
<value>${project.build.testOutputDirectory}</value>
</property>
<property>
<name>test.run.dir</name>
<value>${project.build.directory}/run</value>
</property>
<property>
<name>test.result.dir</name>
<value>${project.build.directory}/results</value>
</property>
<property>
<name>org.slf4j.simpleLogger.defaultLogLevel</name>
<value>debug</value>
</property>
<property>
<name>org.slf4j.simpleLogger.log.com.icegreen.greenmail.util.LineLoggingBuffer</name>
<value>info</value>
</property>
<!--
<property>
<name>org.slf4j.simpleLogger.logFile</name>
<value>${project.build.directory}/tests.log</value>
</property>
-->
<!--
<property>
<name>test.jdbc.driver.className</name>
<value>${test.jdbc.driver.className}</value>
</property>
<property>
<name>test.jdbc.uri</name>
<value>${test.jdbc.uri}</value>
</property>
<property>
<name>test.jdbc.login</name>
<value>${test.jdbc.login}</value>
</property>
<property>
<name>test.jdbc.password</name>
<value>${test.jdbc.password}</value>
</property>
-->
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${webapp.properties}</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>./</classpathPrefix>
<mainClass>com.performance.easyedi.MainKt</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<!-- keep version 2.7 to avoid 3.x behavior with symlinks -->
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<configuration>
<archiveClasses>true</archiveClasses>
<webResources>
<resource>
<directory>${basedir}/src/main/config</directory>
<filtering>true</filtering>
<targetPath>WEB-INF</targetPath>
<includes>
<include>webapp.properties</include>
<include>web.xml</include>
<include>tools.xml</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/main/config/jetty</directory>
<filtering>true</filtering>
<targetPath>WEB-INF/jetty</targetPath>
</resource>
</webResources>
</configuration>
<executions>
<execution>
<id>default-war</id>
<phase>none</phase>
</execution>
<execution>
<id>war-exploded</id>
<!--
<phase>package</phase>
-->
<goals>
<goal>exploded</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>templating-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<id>filter-src</id>
<goals>
<goal>filter-test-sources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty.version}</version>
<configuration>
<scan>3</scan>
<!-- <jettyXmls>${jetty.files}/jetty-http.xml,${jetty.files}/jetty-env.xml,${jetty.files}/jetty-ssl.xml,${jetty.files}/jetty-ssl-context.xml,${jetty.files}/jetty-https.xml</jettyXmls> -->
<jettyXmls>${jetty.files}/jetty-http.xml,${jetty.files}/jetty-env.xml</jettyXmls>
<stopPort>9966</stopPort>
<stopKey>STOP</stopKey>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.eclipse.jetty.http2</groupId>
<artifactId>http2-server</artifactId>
<version>${jetty.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins> </plugins>
</build> </build>
<dependencies>
<!-- main dependencies -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-datetime-jvm</artifactId>
<version>0.3.3</version>
</dependency>
<!-- servlets and mail APIs -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>${servlet.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.5</version>
</dependency>
<!-- auth -->
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>pac4j-oauth</artifactId>
<version>${pac4j.version}</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
<version>2.1.23</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.republicate</groupId>
<artifactId>webapp-slf4j-logger</artifactId>
<version>1.6</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.diogonunes</groupId>
<artifactId>JColor</artifactId>
<version>5.0.1</version>
</dependency>
<!-- mailer -->
<dependency>
<groupId>com.republicate</groupId>
<artifactId>simple-mailer</artifactId>
<version>1.6</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.republicate.kson</groupId>
<artifactId>essential-kson-jvm</artifactId>
<version>2.3</version>
</dependency>
<!-- charset detection
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>70.1</version>
</dependency>
-->
<!-- net clients -->
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version>
</dependency>
<!-- excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.2</version>
</dependency>
<!-- pdf -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.28</version>
</dependency>
<!-- test emails -->
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.6.12</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project> </project>

204
webapp/pom.xml Normal file
View File

@@ -0,0 +1,204 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jeudego.pairgoth</groupId>
<artifactId>engine-parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>webapp</artifactId>
<packaging>war</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<description>PairGoth pairing system</description>
<url>TODO</url>
<properties>
<kotlin.version>1.8.21</kotlin.version>
<kotlin.code.style>official</kotlin.code.style>
<kotlin.compiler.jvmTarget>10</kotlin.compiler.jvmTarget>
<kotlin.compiler.incremental>true</kotlin.compiler.incremental>
<pac4j.version>5.7.1</pac4j.version>
</properties>
<build>
<defaultGoal>package</defaultGoal>
<sourceDirectory>src/main/kotlin</sourceDirectory>
<testSourceDirectory>src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<!-- main dependencies -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-datetime-jvm</artifactId>
<version>0.3.3</version>
</dependency>
<!-- servlets and mail APIs -->
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>${servlet.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>jakarta.mail</artifactId>
<version>1.6.5</version>
</dependency>
<!-- auth -->
<dependency>
<groupId>org.pac4j</groupId>
<artifactId>pac4j-oauth</artifactId>
<version>${pac4j.version}</version>
</dependency>
<!-- logging -->
<dependency>
<groupId>io.github.microutils</groupId>
<artifactId>kotlin-logging-jvm</artifactId>
<version>2.1.23</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>com.republicate</groupId>
<artifactId>webapp-slf4j-logger</artifactId>
<version>1.6</version>
<scope>runtime</scope>
</dependency>
<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>
-->
<dependency>
<groupId>com.diogonunes</groupId>
<artifactId>JColor</artifactId>
<version>5.0.1</version>
</dependency>
<!-- mailer -->
<dependency>
<groupId>com.republicate</groupId>
<artifactId>simple-mailer</artifactId>
<version>1.6</version>
</dependency>
<!-- json -->
<dependency>
<groupId>com.republicate.kson</groupId>
<artifactId>essential-kson-jvm</artifactId>
<version>2.3</version>
</dependency>
<!-- charset detection
<dependency>
<groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId>
<version>70.1</version>
</dependency>
-->
<!-- net clients
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.8.0</version>
</dependency>
-->
<!-- pdf -->
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.28</version>
</dependency>
<!-- test emails -->
<dependency>
<groupId>com.icegreen</groupId>
<artifactId>greenmail</artifactId>
<version>1.6.12</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
</exclusion>
<exclusion>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>