New packaging in progress
This commit is contained in:
@@ -11,8 +11,7 @@
|
|||||||
├── run.bat ................................... Executable run script, windows
|
├── run.bat ................................... Executable run script, windows
|
||||||
├── test.sh ................................... Executable test script, linux
|
├── test.sh ................................... Executable test script, linux
|
||||||
├── application ............................... Executable final packaging
|
├── application ............................... Executable final packaging
|
||||||
├── bootstrap ................................. Executable entry point
|
├── webserver ................................. Web container
|
||||||
├── container ................................. Web container
|
|
||||||
├── docker .................................... Docker packaging
|
├── docker .................................... Docker packaging
|
||||||
│ ├── pairgoth.properties.example ........... Docker property file to instanciate
|
│ ├── pairgoth.properties.example ........... Docker property file to instanciate
|
||||||
│ └── run.sh ................................ Docker launch script
|
│ └── run.sh ................................ Docker launch script
|
||||||
@@ -24,6 +23,7 @@
|
|||||||
│ └── WEB-INF ................... Engine API webapp configuration
|
│ └── WEB-INF ................... Engine API webapp configuration
|
||||||
└── test
|
└── test
|
||||||
└── kotlin ........................ Engine webapp API unit tests
|
└── kotlin ........................ Engine webapp API unit tests
|
||||||
|
└── view-webapp ............................... Web interface
|
||||||
```
|
```
|
||||||
|
|
||||||
## API Webapp sources structure
|
## API Webapp sources structure
|
||||||
@@ -37,7 +37,6 @@ api-webapp/src/main/kotlin/org/jeudego/pairgoth
|
|||||||
├── store .................................. Persistence handlers
|
├── store .................................. Persistence handlers
|
||||||
├── util ................................... Various utilities
|
├── util ................................... Various utilities
|
||||||
└── web .................................... Web interface
|
└── web .................................... Web interface
|
||||||
└── sse ................................ Server Sent Events interface
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Tests are located in `webapp/src/test/kotlin`
|
Tests are located in `webapp/src/test/kotlin`
|
||||||
@@ -48,12 +47,10 @@ Tests are located in `webapp/src/test/kotlin`
|
|||||||
|
|
||||||
You need maven installed.
|
You need maven installed.
|
||||||
|
|
||||||
Copy and adapt `pairgoth.properties.example` towards `pairgoth.properties`.
|
Copy and adapt `pairgoth.properties.example` towards `pairgoth.properties`, if needed. Otherwise pairgoth will use default properties (TODO - list them)
|
||||||
|
|
||||||
Just running `./run.sh` or `./run.bat` shoud build and run the engine .
|
Just running `./run.sh` or `./run.bat` shoud build and run the engine .
|
||||||
|
|
||||||
Run `/test.sh` to test the engine.
|
|
||||||
|
|
||||||
### Docker
|
### Docker
|
||||||
|
|
||||||
Under windows, please use the WSL.
|
Under windows, please use the WSL.
|
||||||
|
@@ -16,10 +16,6 @@
|
|||||||
<description>PairGoth pairing system</description>
|
<description>PairGoth pairing system</description>
|
||||||
<url>TODO</url>
|
<url>TODO</url>
|
||||||
<properties>
|
<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>
|
<pac4j.version>5.7.1</pac4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
@@ -30,7 +26,6 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>compile</id>
|
<id>compile</id>
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>application</artifactId>
|
<artifactId>application</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>jar</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<serverManifestDirectory>${project.build.directory}/servermanifest</serverManifestDirectory>
|
<serverManifestDirectory>${project.build.directory}/servermanifest</serverManifestDirectory>
|
||||||
@@ -21,18 +21,34 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>bootstrap</artifactId>
|
<artifactId>view-webapp</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
|
<type>war</type>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>container</artifactId>
|
<artifactId>webserver</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<finalName>pairgoth-engine</finalName>
|
<finalName>pairgoth-engine</finalName>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<!--
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>
|
||||||
|
org.jeudego.pairgoth.application.PairgothKt
|
||||||
|
</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
-->
|
||||||
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
@@ -47,7 +63,7 @@
|
|||||||
<artifactItems>
|
<artifactItems>
|
||||||
<artifactItem>
|
<artifactItem>
|
||||||
<groupId>${project.groupId}</groupId>
|
<groupId>${project.groupId}</groupId>
|
||||||
<artifactId>bootstrap</artifactId>
|
<artifactId>webserver</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
<outputDirectory>${serverManifestDirectory}</outputDirectory>
|
<outputDirectory>${serverManifestDirectory}</outputDirectory>
|
||||||
<includes>META-INF/MANIFEST.MF</includes>
|
<includes>META-INF/MANIFEST.MF</includes>
|
||||||
@@ -55,6 +71,42 @@
|
|||||||
</artifactItems>
|
</artifactItems>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
<!--
|
||||||
|
<execution>
|
||||||
|
<id>copy-api-war</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactItems>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>api-webapp</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<outputDirectory>webapps</outputDirectory>
|
||||||
|
</artifactItem>
|
||||||
|
</artifactItems>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>copy-view-war</id>
|
||||||
|
<phase>prepare-package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>copy</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<artifactItems>
|
||||||
|
<artifactItem>
|
||||||
|
<groupId>${project.groupId}</groupId>
|
||||||
|
<artifactId>view-webapp</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
<outputDirectory>webapps</outputDirectory>
|
||||||
|
</artifactItem>
|
||||||
|
</artifactItems>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
-->
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
|
@@ -4,24 +4,23 @@
|
|||||||
<id>live-war</id>
|
<id>live-war</id>
|
||||||
<baseDirectory>/</baseDirectory>
|
<baseDirectory>/</baseDirectory>
|
||||||
<formats>
|
<formats>
|
||||||
<format>war</format>
|
<format>jar</format>
|
||||||
</formats>
|
</formats>
|
||||||
<dependencySets>
|
<dependencySets>
|
||||||
<dependencySet>
|
|
||||||
<outputDirectory>/WEB-INF/jetty-server/</outputDirectory>
|
|
||||||
<unpack>true</unpack>
|
|
||||||
<useTransitiveDependencies>false</useTransitiveDependencies>
|
|
||||||
<includes>
|
|
||||||
<include>${project.groupId}:container</include>
|
|
||||||
</includes>
|
|
||||||
</dependencySet>
|
|
||||||
<dependencySet>
|
<dependencySet>
|
||||||
<outputDirectory>/</outputDirectory>
|
<outputDirectory>/</outputDirectory>
|
||||||
<unpack>true</unpack>
|
<unpack>true</unpack>
|
||||||
<useTransitiveDependencies>false</useTransitiveDependencies>
|
<useTransitiveDependencies>false</useTransitiveDependencies>
|
||||||
<includes>
|
<includes>
|
||||||
<include>${project.groupId}:api-webapp</include>
|
<include>${project.groupId}:webserver</include>
|
||||||
<include>${project.groupId}:bootstrap</include>
|
</includes>
|
||||||
|
</dependencySet>
|
||||||
|
<dependencySet>
|
||||||
|
<outputDirectory>/META-INF/webapps/</outputDirectory>
|
||||||
|
<unpack>false</unpack>
|
||||||
|
<useTransitiveDependencies>false</useTransitiveDependencies>
|
||||||
|
<includes>
|
||||||
|
<include>*:war</include>
|
||||||
</includes>
|
</includes>
|
||||||
</dependencySet>
|
</dependencySet>
|
||||||
</dependencySets>
|
</dependencySets>
|
||||||
|
@@ -1,31 +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">
|
|
||||||
<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>
|
|
@@ -1,61 +0,0 @@
|
|||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// 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());
|
|
||||||
|
|
||||||
// CB we want colorized output on linux
|
|
||||||
if (System.getProperty("os.name").equalsIgnoreCase("linux"))
|
|
||||||
{
|
|
||||||
System.setProperty("org.eclipse.jetty.logging.appender.MESSAGE_ESCAPE", "false");
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,171 +0,0 @@
|
|||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// 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);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,83 +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">
|
|
||||||
<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</groupId>
|
|
||||||
<artifactId>jetty-slf4j-impl</artifactId>
|
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.eclipse.jetty</groupId>
|
|
||||||
<artifactId>jetty-jndi</artifactId>
|
|
||||||
<version>${jetty.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<!--
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.slf4j</groupId>
|
|
||||||
<artifactId>slf4j-simple</artifactId>
|
|
||||||
<version>${slf4j.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>
|
|
@@ -1,157 +0,0 @@
|
|||||||
//
|
|
||||||
// ========================================================================
|
|
||||||
// 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.FileReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.eclipse.jetty.server.Server;
|
|
||||||
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
|
|
||||||
import org.eclipse.jetty.util.resource.PathResource;
|
|
||||||
import org.eclipse.jetty.webapp.WebAppContext;
|
|
||||||
|
|
||||||
public class ServerMain
|
|
||||||
{
|
|
||||||
enum OperationalMode
|
|
||||||
{
|
|
||||||
DEV,
|
|
||||||
PROD
|
|
||||||
}
|
|
||||||
|
|
||||||
private Path apiBasePath = null;
|
|
||||||
private Path viewBasePath = null;
|
|
||||||
|
|
||||||
public static void main(String[] args)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
new ServerMain().run();
|
|
||||||
}
|
|
||||||
catch (Throwable t)
|
|
||||||
{
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void run() throws Throwable
|
|
||||||
{
|
|
||||||
// create server and web context
|
|
||||||
Server server = new Server(8080);
|
|
||||||
|
|
||||||
WebAppContext apiContext = new WebAppContext() {
|
|
||||||
@Override
|
|
||||||
public boolean isServerResource(String name, URL url)
|
|
||||||
{
|
|
||||||
return super.isServerResource(name, url) || url.getFile().contains("/WEB-INF/jetty-server/");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
apiContext.setContextPath("/api");
|
|
||||||
|
|
||||||
WebAppContext viewContext = new WebAppContext() {
|
|
||||||
@Override
|
|
||||||
public boolean isServerResource(String name, URL url)
|
|
||||||
{
|
|
||||||
return super.isServerResource(name, url) || url.getFile().contains("/WEB-INF/jetty-server/");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
viewContext.setContextPath("/");
|
|
||||||
|
|
||||||
// pairgoth runtime properties
|
|
||||||
File properties = new File("./pairgoth.properties");
|
|
||||||
if (properties.exists()) {
|
|
||||||
Properties props = new Properties();
|
|
||||||
props.load(new FileReader(properties));
|
|
||||||
for (Map.Entry<Object, Object> entry: props.entrySet()) {
|
|
||||||
String property = (String)entry.getKey();
|
|
||||||
String value = (String)entry.getValue();
|
|
||||||
if (property.startsWith("logger.")) {
|
|
||||||
apiContext.setInitParameter("webapp-slf4j-logger." + property.substring(7), value);
|
|
||||||
} else {
|
|
||||||
System.setProperty("pairgoth." + property, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (getOperationalMode())
|
|
||||||
{
|
|
||||||
case PROD:
|
|
||||||
// Configure as WAR
|
|
||||||
apiContext.setWar(apiBasePath.toString());
|
|
||||||
viewContext.setWar(viewBasePath.toString());
|
|
||||||
break;
|
|
||||||
case DEV:
|
|
||||||
// Configuring from Development Base
|
|
||||||
|
|
||||||
apiContext.setBaseResource(new PathResource(apiBasePath.resolve("src/main/webapp")));
|
|
||||||
// Add webapp compiled classes & resources (copied into place from src/main/resources)
|
|
||||||
Path apiClassesPath = apiBasePath.resolve("target/webapp/WEB-INF/classes");
|
|
||||||
apiContext.setExtraClasspath(apiClassesPath.toAbsolutePath().toString());
|
|
||||||
|
|
||||||
viewContext.setBaseResource(new PathResource(viewBasePath.resolve("src/main/webapp")));
|
|
||||||
// Add webapp compiled classes & resources (copied into place from src/main/resources)
|
|
||||||
Path viewClassesPath = viewBasePath.resolve("target/webapp/WEB-INF/classes");
|
|
||||||
viewContext.setExtraClasspath(viewClassesPath.toAbsolutePath().toString());
|
|
||||||
|
|
||||||
server.setDumpAfterStart(true);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new FileNotFoundException("Unable to configure WebAppContext base resource undefined");
|
|
||||||
}
|
|
||||||
|
|
||||||
server.setHandler(new ContextHandlerCollection(apiContext, viewContext));
|
|
||||||
|
|
||||||
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.apiBasePath = warPath;
|
|
||||||
this.viewBasePath = warPath;
|
|
||||||
return OperationalMode.PROD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We are in development mode, likely building and testing from an IDE.
|
|
||||||
Path apiDevPath = new File("../api-webapp").toPath().toRealPath();
|
|
||||||
Path viewDevPath = new File("../view-webapp").toPath().toRealPath();
|
|
||||||
if (Files.exists(apiDevPath) && Files.isDirectory(apiDevPath) && Files.exists(viewDevPath) && Files.isDirectory(viewDevPath))
|
|
||||||
{
|
|
||||||
this.apiBasePath = apiDevPath;
|
|
||||||
this.viewBasePath = viewDevPath;
|
|
||||||
return OperationalMode.DEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,2 +0,0 @@
|
|||||||
org.eclipse.jetty.util.log.class=org.eclipse.jetty.util.log.StdErrLog
|
|
||||||
org.eclipse.jetty.LEVEL=INFO
|
|
2
debug.sh
2
debug.sh
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mvn package && java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006 -jar application/target/pairgoth-engine.war
|
mvn package && java -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5006 -jar application/target/pairgoth-engine.jar
|
||||||
|
14
pom.xml
14
pom.xml
@@ -56,13 +56,18 @@
|
|||||||
<servlet.api.version>4.0.4</servlet.api.version>
|
<servlet.api.version>4.0.4</servlet.api.version>
|
||||||
<jetty.version>10.0.15</jetty.version>
|
<jetty.version>10.0.15</jetty.version>
|
||||||
<slf4j.version>2.0.7</slf4j.version>
|
<slf4j.version>2.0.7</slf4j.version>
|
||||||
|
|
||||||
|
<!-- kotlin -->
|
||||||
|
<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>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>api-webapp</module>
|
<module>api-webapp</module>
|
||||||
<module>view-webapp</module>
|
<module>view-webapp</module>
|
||||||
<module>container</module>
|
<module>webserver</module>
|
||||||
<module>bootstrap</module>
|
|
||||||
<module>application</module>
|
<module>application</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
@@ -144,6 +149,11 @@
|
|||||||
<artifactId>license-maven-plugin</artifactId>
|
<artifactId>license-maven-plugin</artifactId>
|
||||||
<version>${license.plugin.version}</version>
|
<version>${license.plugin.version}</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</pluginManagement>
|
</pluginManagement>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
2
run.sh
2
run.sh
@@ -1,3 +1,3 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
mvn package && java -jar application/target/pairgoth-engine.war
|
mvn package && java -jar application/target/pairgoth-engine.jar
|
||||||
|
@@ -16,10 +16,6 @@
|
|||||||
<description>PairGoth pairing system</description>
|
<description>PairGoth pairing system</description>
|
||||||
<url>TODO</url>
|
<url>TODO</url>
|
||||||
<properties>
|
<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>
|
<pac4j.version>5.7.1</pac4j.version>
|
||||||
</properties>
|
</properties>
|
||||||
<build>
|
<build>
|
||||||
@@ -30,7 +26,6 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jetbrains.kotlin</groupId>
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
<artifactId>kotlin-maven-plugin</artifactId>
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
<version>${kotlin.version}</version>
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>compile</id>
|
<id>compile</id>
|
||||||
|
170
webserver/pom.xml
Normal file
170
webserver/pom.xml
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
<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>webserver</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
<description>Pairgoth Launcher</description>
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib-jdk8</artifactId>
|
||||||
|
<version>${kotlin.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-test-junit5</artifactId>
|
||||||
|
<version>1.8.21</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.jupiter</groupId>
|
||||||
|
<artifactId>junit-jupiter-engine</artifactId>
|
||||||
|
<version>5.9.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-webapp</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-slf4j-impl</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.eclipse.jetty</groupId>
|
||||||
|
<artifactId>jetty-jndi</artifactId>
|
||||||
|
<version>${jetty.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.11.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<sourceDirs>
|
||||||
|
<source>src/main/kotlin</source>
|
||||||
|
</sourceDirs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>test-compile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>test-compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<!--
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>1.6.0</version>
|
||||||
|
<configuration>
|
||||||
|
<mainClass>org.jeudego.pairgoth.application.PairgothKt</mainClass>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
-->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
|
||||||
|
<mainClass>org.jeudego.pairgoth.application.PairgothKt</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>testCompile</id>
|
||||||
|
<phase>test-compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>testCompile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
<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>
|
@@ -0,0 +1,50 @@
|
|||||||
|
package org.jeudego.pairgoth.application
|
||||||
|
|
||||||
|
import org.apache.commons.io.FileUtils
|
||||||
|
import org.eclipse.jetty.server.Server
|
||||||
|
import java.net.JarURLConnection
|
||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Path
|
||||||
|
import java.util.jar.JarFile
|
||||||
|
|
||||||
|
|
||||||
|
fun main(vararg args: String) {
|
||||||
|
try {
|
||||||
|
extractWarFiles()
|
||||||
|
launchServer()
|
||||||
|
} catch (t: Throwable) {
|
||||||
|
t.printStackTrace(System.err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun extractWarFiles() {
|
||||||
|
// val jarLocation = object{}::class.java.protectionDomain.codeSource.location
|
||||||
|
// prepare output directory
|
||||||
|
val tmp = System.getProperty("java.io.tmpdir")
|
||||||
|
val targetPath = Path.of("${tmp}/pairgoth/webapps")
|
||||||
|
FileUtils.deleteDirectory(targetPath.toFile())
|
||||||
|
Files.createDirectories(targetPath)
|
||||||
|
|
||||||
|
// extract wars
|
||||||
|
val webappsFolderURL = object{}::class.java.enclosingClass.getResource("/META-INF/webapps") ?: throw Error("webapps not found")
|
||||||
|
val jarConnection = webappsFolderURL.openConnection() as JarURLConnection
|
||||||
|
val jarFile: JarFile = jarConnection.getJarFile()
|
||||||
|
jarFile.entries().toList().filter { entry ->
|
||||||
|
entry.name.startsWith(jarConnection.entryName)
|
||||||
|
}.forEach { entry ->
|
||||||
|
if (!entry.isDirectory) {
|
||||||
|
jarFile.getInputStream(entry).use { entryInputStream ->
|
||||||
|
Files.copy(entryInputStream, targetPath.resolve(entry.name.removePrefix("META-INF/webapps/")))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun launchServer() {
|
||||||
|
|
||||||
|
// create server
|
||||||
|
val server = Server(8080)
|
||||||
|
|
||||||
|
// register webapps
|
||||||
|
// server.
|
||||||
|
}
|
Reference in New Issue
Block a user