Finished work on the JPackage call, placed it inside separate profile Image.
This commit is contained in:
parent
08f95c3732
commit
ced77b8e6b
12
README.md
12
README.md
@ -2,6 +2,14 @@
|
||||
|
||||
Example Maven Project for a JavaFX Application.
|
||||
|
||||
Maven modules are configured so that even Images are build (including JPackage app-image).
|
||||
This projects includes multiple plugins:
|
||||
- Static code analysis with PMD and Spotbugs
|
||||
- Check of dependency updates during build
|
||||
- Build of an App-Image using JPackage
|
||||
|
||||
Project includes PMD and spotbugs!
|
||||
The application is no longer a modular application so there are no problems with dependencies that are not providing a
|
||||
module-info.
|
||||
|
||||
** Build the Image **
|
||||
To build the image, the profile Image must be used:
|
||||
```./mvnw -DImage install```
|
||||
|
||||
100
pom.xml
100
pom.xml
@ -17,18 +17,17 @@
|
||||
<link.name>${project.artifactId}</link.name>
|
||||
<launcher>${project.artifactId}</launcher>
|
||||
<appName>${project.artifactId}</appName>
|
||||
<main.class>de.kneitzel.JavaFXApp</main.class>
|
||||
<main.module>FXAppModule</main.module>
|
||||
<main.class>de.kneitzel.Main</main.class>
|
||||
<java.version>17</java.version>
|
||||
<required.maven.version>3.6.3</required.maven.version>
|
||||
<jar.file>javafxapp</jar.file>
|
||||
<jar.filename>${project.artifactId}-${project.version}</jar.filename>
|
||||
|
||||
<!-- Dependency versions -->
|
||||
<junit.version>5.9.1</junit.version>
|
||||
<javafx.version>19</javafx.version>
|
||||
<log4j.version>2.19.0</log4j.version>
|
||||
<lombok.version>1.18.24</lombok.version>
|
||||
<jetbrains.annotations.version>23.0.0</jetbrains.annotations.version>
|
||||
<jetbrains.annotations.version>24.0.1</jetbrains.annotations.version>
|
||||
<junit.version>5.9.2</junit.version>
|
||||
<lombok.version>1.18.26</lombok.version>
|
||||
<mockito.version>5.2.0</mockito.version>
|
||||
|
||||
<!-- Plugin dependencies -->
|
||||
<maven.clean.plugin>3.2.0</maven.clean.plugin>
|
||||
@ -44,7 +43,7 @@
|
||||
<moditect.maven.plugin>1.0.0.RC2</moditect.maven.plugin>
|
||||
<jpackage.maven.plugin>0.1.3</jpackage.maven.plugin>
|
||||
<maven.pmd.version>3.16.0</maven.pmd.version>
|
||||
<pmd.version>6.50.0</pmd.version>
|
||||
<pmd.version>6.55.0</pmd.version>
|
||||
<codehaus.version.plugin>2.11.0</codehaus.version.plugin>
|
||||
<spotbugs.maven.plugin>4.7.2.0</spotbugs.maven.plugin>
|
||||
<spotbugs.version>4.7.3</spotbugs.version>
|
||||
@ -58,6 +57,7 @@
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- JavaFX dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
@ -79,6 +79,7 @@
|
||||
<version>${javafx.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Lombok -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
@ -86,6 +87,34 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit 5 -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-params</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Mockito -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<version>${mockito.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Dependency used for @NotNull / @Nullable -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
@ -94,28 +123,10 @@
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-api</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
<artifactId>log4j-core</artifactId>
|
||||
<version>${log4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-engine</artifactId>
|
||||
<version>${junit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>${jar.file}</finalName>
|
||||
<finalName>${jar.filename}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -290,6 +301,26 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<profiles>
|
||||
|
||||
<!-- Profile that adds JLink and JPackage runs.
|
||||
|
||||
Add -PImage or -DImage to use this profile.
|
||||
-->
|
||||
<profile>
|
||||
<id>Image</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>Image</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<finalName>${jar.filename}</finalName>
|
||||
<plugins>
|
||||
<!-- Copy dependencies -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
@ -304,16 +335,7 @@
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/modules</outputDirectory>
|
||||
<excludeGroupIds>org.openjfx</excludeGroupIds>
|
||||
<includeScope>runtime</includeScope>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>${project.packaging}</type>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
@ -364,10 +386,11 @@
|
||||
<addmodule>javafx.controls</addmodule>
|
||||
<addmodule>javafx.graphics</addmodule>
|
||||
<addmodule>javafx.fxml</addmodule>
|
||||
<addmodule>javafx.web</addmodule>
|
||||
</addmodules>
|
||||
<mainclass>${main.class}</mainclass>
|
||||
<input>${project.build.directory}/modules</input>
|
||||
<mainjar>${jar.file}.jar</mainjar>
|
||||
<mainjar>${jar.filename}.jar</mainjar>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@ -380,4 +403,7 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
</project>
|
||||
|
||||
@ -1,24 +1,17 @@
|
||||
package de.kneitzel;
|
||||
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class JavaFXApp extends Application {
|
||||
static final Logger logger = LogManager.getLogger(JavaFXApp.class);
|
||||
|
||||
@Override
|
||||
public void start(Stage primaryStage) throws IOException {
|
||||
public void start(Stage primaryStage) {
|
||||
try {
|
||||
primaryStage.setTitle("Hello World!");
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("MainWindow.fxml"));
|
||||
@ -26,16 +19,12 @@ public class JavaFXApp extends Application {
|
||||
primaryStage.setScene(new Scene(root));
|
||||
primaryStage.show();
|
||||
} catch (Exception ex) {
|
||||
logger.error("Exception!", ex);
|
||||
System.out.println("Exception: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
logger.warn("Starting ...");
|
||||
try {
|
||||
launch(args);
|
||||
} catch (Exception ex) {
|
||||
logger.error("Exception!", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
15
src/main/java/de/kneitzel/Main.java
Normal file
15
src/main/java/de/kneitzel/Main.java
Normal file
@ -0,0 +1,15 @@
|
||||
package de.kneitzel;
|
||||
|
||||
/**
|
||||
* Another Main class as workaround when the JavaFX Application ist started without
|
||||
* taking care os Classloader Requirements of JavaFX. (Important when starting from inside NetBeans!)
|
||||
*/
|
||||
public class Main {
|
||||
/**
|
||||
* Additional main methode to start Application.
|
||||
* @param args Commandline Arguments.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
JavaFXApp.main(args);
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration status="INFO">
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" />
|
||||
</Console>
|
||||
<File name="MyFile" fileName="all.log" immediateFlush="false" append="false">
|
||||
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
|
||||
</File>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<Root level="debug">
|
||||
<AppenderRef ref="Console" />
|
||||
<AppenderRef ref="MyFile"/>
|
||||
</Root>
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Loading…
x
Reference in New Issue
Block a user