now using packr for distribution

I switched from launch4j to packr, because launch4j got flagged as false positive.
Because packr couldn't deal with the registry library (SimplyRegistry used cmd to call reg) i implemented a packr friendly method.
I couldn't used the WindowsPreferences JNI from Java, because it does not support DWORDs which are needed to get the Steam Process!
This commit is contained in:
Niklas 2020-04-01 02:03:13 +02:00
parent 43b6572422
commit ccd7bfe82c
16 changed files with 244 additions and 188 deletions

4
.gitignore vendored
View File

@ -3,5 +3,5 @@
out/ out/
META-INF/ META-INF/
target/ target/
gui/target/ */target/
patcher/target/ dist/src/main/resources/jre.zip

View File

@ -13,22 +13,46 @@ Open ``gui/src/main/resources/arma3launcher.json`` and edit the variables as you
To configure your logo replace the _logo\*_ files inside the ``gui/src/main/resources/icons/`` folder. To configure your logo replace the _logo\*_ files inside the ``gui/src/main/resources/icons/`` folder.
### Build ### Build
To build this project simply run To build this project you need JDK12+ and maven.
To compile a single module run
```bash
mvn package -pl {gui/patcher}
```
To compile the project for distribution you a bundled JRE in ``dist/src/main/resources/jre.zip``.
A bundled JRE should be an OpenJDK with the following folder structure:
```
jre.zip
└── jre
   ├── bin
   ├── conf
   ├── include
   ├── jmods
   ├── legal
   ├── lib
   └── release
```
After that run
```bash ```bash
mvn package mvn package
``` ```
After building the package you find the universal auto patcher inside ``patcher/target/patcher.jar``. After building the project for distribution you find the universal auto patcher inside ``patcher/target/patcher.jar``.
Inside ``gui/target/`` you find the gui as jar, jar with dependencies, jar wrapper build with launch4j and an assembled zip file. Inside ``gui/target/`` you find the gui as jar and jar with dependencies.
The jar wrapper build with <a href="https://github.com/libgdx/packr/" target="_blank">packr</a> can be found as an assembled zip file
inside the ``dis/target/`` folder.
### Distribute ### Distribute
After building the package you find inside the ``gui/target/`` folder an zip file. After building the package you find inside the ``dist/target/`` folder an zip file.
This zip file contains an empty ``jre/`` and an empty ``logs/`` folder. This zip file contains the bundled ``jre/`` folder and an empty ``logs/`` folder.
Bundle your own JRE with minimum JRE12 and put it in the ``*.zip/jre/``.
The ``jre/`` folder should then contain ``{bin,conf,lib}/``. **Please note that the .exe does not have an icon!!**
I tried [*rcedit*](https://github.com/electron/rcedit) to edit the resource icon in assembly but many anti virus scanner flag the wrapper than an false positive!
Linux/Mac users can run the *arma3launcher-gui.jar*. Linux/Mac users can run the *arma3launcher-gui.jar*.
Windows users can simply run the *arma3launcher.exe* and the launch4j wrapper prioritize the local JRE else use the bundled jre. Windows users can simply run the *arma3launcher.exe* and the packr wrapper prioritize the local JRE else use the bundled jre.
### Server side setup ### Server side setup
For the server side you need a simple webserver with no special configuration. For the server side you need a simple webserver with no special configuration.

BIN
dist/packr.jar vendored Normal file

Binary file not shown.

88
dist/pom.xml vendored Normal file
View File

@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>arma3launcher</artifactId>
<groupId>de.mc8051</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dist</artifactId>
<build>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>make-exe</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<outputFile>target/packr-exec.log</outputFile>
<workingDirectory>./</workingDirectory>
<arguments>
<argument>-jar</argument>
<argument>packr.jar</argument>
<argument>--platform</argument>
<argument>windows64</argument>
<argument>--jdk</argument>
<argument>src/main/resources/jre.zip</argument>
<argument>--executable</argument>
<argument>${project.parent.artifactId}</argument>
<argument>--output</argument>
<argument>target/launcher/</argument>
<argument>--mainclass</argument>
<argument>${project.parent.groupId}.${project.parent.artifactId}.ArmA3Launcher</argument>
<argument>--classpath</argument>
<argument>${project.parent.artifactId}-gui.jar</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${project.parent.artifactId}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/main/zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

Before

Width:  |  Height:  |  Size: 52 KiB

After

Width:  |  Height:  |  Size: 52 KiB

51
dist/src/main/zip.xml vendored Normal file
View File

@ -0,0 +1,51 @@
<!--
~ This file is part of the arma3launcher distribution.
~ Copyright (c) 2020-2020 Niklas Schütrumpf (Gurkengewuerz)
~
~ This program is free software: you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation, version 3.
~
~ This program is distributed in the hope that it will be useful, but
~ WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
~ General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>./</baseDirectory>
<files>
<file>
<source>../gui/target/${project.parent.artifactId}-gui-${gui.version}.jar</source>
<destName>${project.parent.artifactId}-gui.jar</destName>
<outputDirectory>./</outputDirectory>
</file>
</files>
<fileSets>
<fileSet>
<directory>./</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>target/launcher/</directory>
<outputDirectory>./</outputDirectory>
</fileSet>
</fileSets>
</assembly>

View File

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!-- <requestedExecutionLevel level="asInvoker" uiAccess="false"/> -->
<!-- <requestedExecutionLevel level="highestAvailable" uiAccess="false"/> -->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

View File

@ -10,8 +10,14 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<artifactId>gui</artifactId> <artifactId>gui</artifactId>
<version>0.1.1001</version>
<dependencies> <dependencies>
<dependency> <dependency>
@ -29,11 +35,6 @@
<artifactId>flatlaf</artifactId> <artifactId>flatlaf</artifactId>
<version>0.28</version> <version>0.28</version>
</dependency> </dependency>
<dependency>
<groupId>com.github.RalleYTN</groupId>
<artifactId>SimpleRegistry</artifactId>
<version>java8-7949ac7f06-1</version>
</dependency>
<dependency> <dependency>
<groupId>org.ini4j</groupId> <groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId> <artifactId>ini4j</artifactId>
@ -102,7 +103,7 @@
<phase>package</phase> <phase>package</phase>
<configuration> <configuration>
<finalName>${parent.artifactId}-${project.artifactId}-${project.version}</finalName> <finalName>${project.parent.artifactId}-${project.artifactId}-${gui.version}</finalName>
<appendAssemblyId>false</appendAssemblyId> <appendAssemblyId>false</appendAssemblyId>
<descriptorRefs> <descriptorRefs>
<descriptorRef> <descriptorRef>
@ -111,69 +112,11 @@
</descriptorRefs> </descriptorRefs>
<archive> <archive>
<manifest> <manifest>
<mainClass>${project.groupId}.${parent.artifactId}.ArmA3Launcher</mainClass> <mainClass>${project.parent.groupId}.${project.parent.artifactId}.ArmA3Launcher</mainClass>
</manifest> </manifest>
</archive> </archive>
</configuration> </configuration>
</execution> </execution>
<execution>
<id>dist</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<finalName>${parent.artifactId}-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.25</version>
<executions>
<execution>
<id>l4j-gui</id>
<phase>prepare-package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<dontWrapJar>true</dontWrapJar>
<headerType>gui</headerType>
<outfile>target/${parent.artifactId}.exe</outfile>
<jar>${parent.artifactId}-${project.artifactId}.jar</jar>
<jre>
<path>jre/</path>
<bundledJre64Bit>true</bundledJre64Bit>
<bundledJreAsFallback>true</bundledJreAsFallback>
<minVersion>12</minVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
<icon>src/main/resources/icons/logo.ico</icon>
<manifest>launcher.exe.manifest</manifest>
<versionInfo>
<fileVersion>1.0.0.0</fileVersion>
<txtFileVersion>1.0.0.0</txtFileVersion>
<fileDescription>Launcher</fileDescription>
<copyright>mc8051</copyright>
<productVersion>1.0.0.0</productVersion>
<txtProductVersion>1.0.0.0</txtProductVersion>
<productName>Launcher</productName>
<companyName></companyName>
<internalName>${parent.artifactId}</internalName>
<originalFilename>${parent.artifactId}.exe</originalFilename>
<trademarks></trademarks>
<language>ENGLISH_US</language>
</versionInfo>
</configuration>
</execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -0,0 +1,28 @@
package de.mc8051.arma3launcher;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WinRegistry {
public static String getValue(String keyPath, String keyName) throws IOException, InterruptedException {
Process keyReader = Runtime.getRuntime().exec(
"reg query \"" + keyPath + "\" /v \"" + keyName + "\"");
BufferedReader outputReader;
String readLine;
StringBuffer outputBuffer = new StringBuffer();
outputReader = new BufferedReader(new InputStreamReader(
keyReader.getInputStream()));
while ((readLine = outputReader.readLine()) != null) {
outputBuffer.append(readLine);
}
String[] outputComponents = outputBuffer.toString().split(" ");
keyReader.waitFor();
return outputComponents[outputComponents.length - 1];
}
}

View File

@ -1,9 +1,8 @@
package de.mc8051.arma3launcher.steam; package de.mc8051.arma3launcher.steam;
import de.mc8051.arma3launcher.utils.SteamUtils; import de.mc8051.arma3launcher.WinRegistry;
import de.mc8051.arma3launcher.interfaces.Observer; import de.mc8051.arma3launcher.interfaces.Observer;
import de.ralleytn.simple.registry.Key; import de.mc8051.arma3launcher.utils.SteamUtils;
import de.ralleytn.simple.registry.Registry;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,31 +16,32 @@ import java.util.logging.Logger;
public class SteamTimer extends TimerTask { public class SteamTimer extends TimerTask {
private static ArrayList<Observer> observers = new ArrayList<>(); private static ArrayList<Observer> observers = new ArrayList<>();
private static boolean old_steamrunning = false;
public static boolean steam_running = false; public static boolean steam_running = false;
private static boolean old_arma_running = false;
public static boolean arma_running = false; public static boolean arma_running = false;
public static boolean firstRun = false;
@Override @Override
public void run() { public void run() {
String OS = System.getProperty("os.name").toUpperCase(); String OS = System.getProperty("os.name").toUpperCase();
if (!OS.contains("WIN")) return; if (!OS.contains("WIN")) return;
boolean old_steamrunning = steam_running; old_steamrunning = steam_running;
boolean old_arma_running = arma_running; old_arma_running = arma_running;
try { try {
if(!SteamUtils.findProcess("steam.exe")) { if (!SteamUtils.findProcess("steam.exe")) {
steam_running = false; steam_running = false;
if(old_steamrunning != steam_running) notifyObservers("steamtimer"); notifyObservers("steamtimer");
return; return;
} }
Key activeSteamUserKey = Registry.getKey(Registry.HKEY_CURRENT_USER + "\\Software\\Valve\\Steam\\ActiveProcess");
String activeSteamUser = activeSteamUserKey.getValueByName("ActiveUser").getRawValue(); String activeSteamUser = WinRegistry.getValue("HKEY_CURRENT_USER\\Software\\Valve\\Steam\\ActiveProcess", "ActiveUser");
if (activeSteamUser.equals("0x0")) {
if(activeSteamUser.equals("0x0")) {
steam_running = false; steam_running = false;
if(old_steamrunning != steam_running) notifyObservers("steamtimer"); notifyObservers("steamtimer");
return; return;
} }
@ -52,8 +52,8 @@ public class SteamTimer extends TimerTask {
|| SteamUtils.findProcess("arma3battleye.exe") || SteamUtils.findProcess("arma3battleye.exe")
|| SteamUtils.findProcess("arma3launcher.exe"); || SteamUtils.findProcess("arma3launcher.exe");
if(old_steamrunning != steam_running || old_arma_running != arma_running) notifyObservers("steamtimer"); notifyObservers("steamtimer");
} catch (IOException e) { } catch (IOException | InterruptedException e) {
steam_running = false; steam_running = false;
arma_running = false; arma_running = false;
notifyObservers("steamtimer"); notifyObservers("steamtimer");
@ -66,6 +66,9 @@ public class SteamTimer extends TimerTask {
} }
public void notifyObservers(String obj) { public void notifyObservers(String obj) {
for(Observer o : observers) o.update(obj); if (old_arma_running != arma_running || old_steamrunning != steam_running || !firstRun) {
for (Observer o : observers) o.update(obj);
firstRun = true;
}
} }
} }

View File

@ -2,12 +2,12 @@ package de.mc8051.arma3launcher.utils;
import de.mc8051.arma3launcher.Parameter; import de.mc8051.arma3launcher.Parameter;
import de.mc8051.arma3launcher.Parameters; import de.mc8051.arma3launcher.Parameters;
import de.mc8051.arma3launcher.WinRegistry;
import de.mc8051.arma3launcher.objects.Modset; import de.mc8051.arma3launcher.objects.Modset;
import de.ralleytn.simple.registry.Key;
import de.ralleytn.simple.registry.Registry;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
@ -23,19 +23,19 @@ import java.util.stream.Collectors;
public class ArmaUtils { public class ArmaUtils {
public static Path getInstallationPath() { public static Path getInstallationPath() {
Key regKey = null; String regKey = null;
try { try {
regKey = Registry.getKey(Registry.HKEY_LOCAL_MASHINE + "\\SOFTWARE\\bohemia interactive\\arma 3"); regKey = WinRegistry.getValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\bohemia interactive\\arma 3", "main");
} catch (IOException ignored) { } catch (IOException | InterruptedException ignored) {
try { try {
regKey = Registry.getKey("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\bohemia interactive\\arma 3"); regKey = WinRegistry.getValue("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\bohemia interactive\\arma 3", "main");
} catch (IOException e) { } catch (IOException | InterruptedException e) {
Logger.getLogger(ArmaUtils.class.getName()).log(Level.INFO, "Arma patch cant be detected automatically"); Logger.getLogger(ArmaUtils.class.getName()).log(Level.INFO, "Arma patch cant be detected automatically");
} }
} }
if (regKey == null) return null; if (regKey == null) return null;
final Path main = Paths.get(regKey.getValueByName("main").getRawValue()); final Path main = Paths.get(regKey);
if (!checkArmaPath(main)) return null; if (!checkArmaPath(main)) return null;
return main; return main;
} }

View File

@ -91,32 +91,6 @@ nicht jeder Fehler unsererseits behoben werden kann.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br/> OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br/>
</tt> </tt>
<br/> <br/>
<h2>com.github.RalleYTN.SimpleRegistry</h2>
<a href="">https://github.com/RalleYTN/SimpleRegistry</a><br/>
<tt>
MIT License<br/>
<br/>
Copyright (c) 2017 Ralph Niemitz<br/>
<br/>
Permission is hereby granted, free of charge, to any person obtaining a copy<br/>
of this software and associated documentation files (the "Software"), to deal<br/>
in the Software without restriction, including without limitation the rights<br/>
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell<br/>
copies of the Software, and to permit persons to whom the Software is<br/>
furnished to do so, subject to the following conditions:<br/>
<br/>
The above copyright notice and this permission notice shall be included in all<br/>
copies or substantial portions of the Software.<br/>
<br/>
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br/>
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br/>
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE<br/>
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br/>
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,<br/>
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE<br/>
SOFTWARE.<br/>
</tt>
<br/>
<h2>com.typesafe.config</h2> <h2>com.typesafe.config</h2>
<a href="">https://github.com/lightbend/config</a><br/> <a href="">https://github.com/lightbend/config</a><br/>
<tt> <tt>

View File

@ -1,2 +1,2 @@
version=${project.version} version=${gui.version}
artifactId=${project.artifactId} artifactId=${project.parent.artifactId}

View File

@ -1,41 +0,0 @@
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>distribution</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>true</includeBaseDirectory>
<baseDirectory>./</baseDirectory>
<files>
<file>
<source>target/${parent.artifactId}-${project.artifactId}-${project.version}.jar</source>
<destName>${parent.artifactId}-${project.artifactId}.jar</destName>
<outputDirectory>./</outputDirectory>
</file>
<file>
<source>target/${parent.artifactId}.exe</source>
<outputDirectory>./</outputDirectory>
</file>
</files>
<fileSets>
<fileSet>
<directory>./</directory>
<outputDirectory>logs</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>./</directory>
<outputDirectory>jre</outputDirectory>
<excludes>
<exclude>*/**</exclude>
</excludes>
</fileSet>
</fileSets>
</assembly>

View File

@ -58,7 +58,7 @@
</descriptorRefs> </descriptorRefs>
<archive> <archive>
<manifest> <manifest>
<mainClass>${project.groupId}.${parent.artifactId}.Arma3LauncherPatcher</mainClass> <mainClass>${project.parent.groupId}.${project.parent.artifactId}.Arma3LauncherPatcher</mainClass>
</manifest> </manifest>
</archive> </archive>
</configuration> </configuration>

12
pom.xml
View File

@ -4,20 +4,18 @@
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>
<properties>
<gui.version>0.1.1002</gui.version>
</properties>
<groupId>de.mc8051</groupId> <groupId>de.mc8051</groupId>
<artifactId>arma3launcher</artifactId> <artifactId>arma3launcher</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<modules> <modules>
<module>gui</module> <module>gui</module>
<module>patcher</module> <module>patcher</module>
<module>dist</module>
</modules> </modules>
</project> </project>