feat: добавляем win/linux профили для сборки с разными javafx

This commit is contained in:
SashegDev
2026-05-05 11:33:30 +00:00
parent a46ef3e834
commit 70c4815032
3 changed files with 76 additions and 7 deletions
+9
View File
@@ -48,6 +48,12 @@
<exclude>**/*-linux.jar</exclude>
</excludes>
</filter>
<filter>
<artifact>*:javafx-*</artifact>
<excludes>
<exclude>*</exclude>
</excludes>
</filter>
</filters>
<dependencySet>
<outputDirectory>/</outputDirectory>
@@ -132,6 +138,9 @@
<copy>
<fileset />
</copy>
<copy>
<fileset />
</copy>
<zip />
</target>
</configuration>
+56 -4
View File
@@ -17,6 +17,9 @@
<project.inceptionYear>2026</project.inceptionYear>
<project.description>ZernMC Launcher - just a minimalistic launcher by SashegDev</project.description>
<mainClass>me.sashegdev.zernmc.launcher.Main</mainClass>
<javafx.classifier>win</javafx.classifier>
<os.suffix>win</os.suffix>
<skip.launch4j>false</skip.launch4j>
</properties>
<dependencies>
@@ -82,6 +85,20 @@
<version>21.0.2</version>
<classifier>win</classifier>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21.0.2</version>
<classifier>linux</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>21.0.2</version>
<classifier>linux</classifier>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
@@ -178,11 +195,14 @@
</executions>
</plugin>
<!-- Launch4j для создания .exe -->
<!-- Launch4j для создания .exe (только для Windows) -->
<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>2.5.0</version>
<configuration>
<skip>${skip.launch4j}</skip>
</configuration>
<executions>
<execution>
<id>l4j</id>
@@ -238,13 +258,15 @@
<fileset dir="${user.home}/launcher/jre/jre21"/>
</copy>
<!-- Копируем JavaFX JAR в builds -->
<!-- Копируем JavaFX JAR в builds (только для текущей OS) -->
<copy todir="../server/builds/lib-javafx" overwrite="true">
<fileset dir="${project.build.directory}/lib-javafx"/>
<fileset dir="${project.build.directory}/lib-javafx">
<include>*${javafx.classifier}.jar</include>
</fileset>
</copy>
<!-- Создаём zip с .exe, jre21 и lib-javafx (без .jar и build.version) -->
<zip destfile="../server/builds/ZernMCLauncher-${project.version}.zip"
<zip destfile="../server/builds/ZernMCLauncher-${project.version}-${os.suffix}.zip"
basedir="../server/builds"
includes="ZernMCLauncher.exe,jre21/**,lib-javafx/**"
excludes="*.jar,build.version"/>
@@ -279,5 +301,35 @@
<server.url>http://87.120.187.36:1582</server.url>
</properties>
</profile>
<!-- ==================== WINDOWS BUILD ==================== -->
<profile>
<id>win</id>
<activation>
<os>
<family>windows</family>
</os>
</activation>
<properties>
<javafx.classifier>win</javafx.classifier>
<os.suffix>win</os.suffix>
<skip.launch4j>false</skip.launch4j>
</properties>
</profile>
<!-- ==================== LINUX BUILD ==================== -->
<profile>
<id>linux</id>
<activation>
<os>
<family>unix</family>
</os>
</activation>
<properties>
<javafx.classifier>linux</javafx.classifier>
<os.suffix>linux</os.suffix>
<skip.launch4j>true</skip.launch4j>
</properties>
</profile>
</profiles>
</project>
@@ -186,12 +186,20 @@ public class Main {
try {
String javaPath = System.getProperty("java.home") + "/bin/java";
String jarPath = getCurrentJarPath().toAbsolutePath().toString();
String launcherDir = jarPath.substring(0, jarPath.lastIndexOf(java.io.File.separator));
String javafxPath = launcherDir + java.io.File.separator + "lib-javafx";
System.out.println(ZAnsi.brightGreen("Перезапуск лаунчера с новой версией..."));
new ProcessBuilder(javaPath, "-jar", jarPath)
.inheritIO()
.start();
ProcessBuilder pb = new ProcessBuilder(
javaPath,
"--module-path=" + javafxPath,
"--add-modules=javafx.controls,javafx.web",
"--add-reads=javafx.graphics=ALL-UNNAMED",
"-jar", jarPath
);
pb.inheritIO();
pb.start();
System.exit(0);
} catch (Exception e) {