Template
Update Maven wrapper and project dependencies
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
# Image Creation
|
||||
|
||||
If the application is to be distributed, the translated program and possibly installation instructions are required.
|
||||
|
||||
Creating the image involves two steps:
|
||||
|
||||
Provision of all necessary files. This includes the translated classes and the application's resources, as well as all dependencies.
|
||||
Creation of an "image": A directory structure with files along with a binary that can be executed.
|
||||
|
||||
## Invocation
|
||||
|
||||
To build the image, start Maven with the Image profile and the install goal.
|
||||
Since there are sometimes problems when files need to be overwritten, a clean should be run first.
|
||||
|
||||
This can be done in one run:
|
||||
```shell
|
||||
mvnw -PImage clean install
|
||||
```
|
||||
|
||||
## Description of theImage Profile
|
||||
|
||||
### The Profile
|
||||
|
||||
```xml
|
||||
<profile>
|
||||
<id>Image</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>Image</name>
|
||||
</property>
|
||||
</activation>
|
||||
<build>
|
||||
<plugins>
|
||||
|
||||
<!-- ... -->
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
```
|
||||
|
||||
- The profile has an ID: Image. This allows the profile to be selected using -PImage.
|
||||
- Additionally, the profile can be selected using a define: -DImage
|
||||
- The profile itself then contains plugins.
|
||||
|
||||
### maven-dependency-plugin
|
||||
|
||||
```xml
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<version>${maven.dependency.plugin}</version>
|
||||
<executions>
|
||||
<!-- erstmal Abhängigkeiten für den Class-Path kopieren -->
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/modules</outputDirectory>
|
||||
<includeScope>runtime</includeScope>
|
||||
<overWriteReleases>false</overWriteReleases>
|
||||
<overWriteSnapshots>false</overWriteSnapshots>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
||||
<!-- dazu noch das Projekt-JAR -->
|
||||
<execution>
|
||||
<id>copy</id>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.directory}/modules</outputDirectory>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>${project.artifactId}</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>${project.packaging}</type>
|
||||
<destFileName>${project.build.finalName}.jar</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
<overWriteIfNewer>true</overWriteIfNewer>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
```
|
||||
|
||||
The Maven Dependency Plugin is used to copy the required files. This is done in two steps:
|
||||
|
||||
1. All dependencies are copied.
|
||||
2. The produced artifact (the jar file with the project code) is copied.
|
||||
|
||||
#### copy-dependencies
|
||||
The copy-dependencies execution within the maven-dependency-plugin is designed to automate the process of copying all
|
||||
necessary runtime dependencies into a specified output directory. This execution is vital for ensuring that all runtime
|
||||
components required by the application are available in the deployment environment. The configuration ensures that
|
||||
dependencies are handled efficiently during the package phase of the build process.
|
||||
|
||||
Key aspects of the copy-dependencies execution include:
|
||||
|
||||
- **Phase**: It is configured to run during the package phase, which is the ideal time to gather all dependencies needed
|
||||
for the packaged application.
|
||||
- **Goals**: The copy-dependencies goal is utilized to perform the action of copying dependencies.
|
||||
- **Configuration**: Important configuration settings include:
|
||||
- - **outputDirectory**: Specifies the directory where all dependencies will be copied, typically a subdirectory in the
|
||||
build directory such as /modules.
|
||||
- - **includeScope**: Set to runtime to ensure that only dependencies needed at runtime are included, which helps in
|
||||
reducing the size and complexity of the deployment.
|
||||
- - **overWriteReleases, overWriteSnapshots, and overWriteIfNewer**: These settings manage how existing files in the
|
||||
target directory are handled. They prevent overwriting of stable release versions and snapshot versions unless a newer
|
||||
version is being copied, which helps in maintaining the integrity and up-to-dateness of the dependency files.
|
||||
|
||||
This configuration ensures that all necessary dependencies are prepared and available in the correct location before the application is packaged, facilitating a smooth transition to the assembly and deployment stages.
|
||||
|
||||
#### copy project artefact
|
||||
The copy project artifact execution in the maven-dependency-plugin is tailored to facilitate the copying of the final
|
||||
project artifact, typically the executable JAR file, into a designated output directory. This step is critical as it
|
||||
ensures that the most current and verified version of the application is available for packaging and deployment.
|
||||
|
||||
Key aspects of the copy project artifact execution include:
|
||||
|
||||
- **Phase**: Configured to execute during the install phase, which follows the build and verification processes.
|
||||
This timing is crucial to ensure that only fully built and tested artifacts are moved forward in the deployment pipeline.
|
||||
- **Goals**: Utilizes the copy goal to perform the file copying operation.
|
||||
- **Configuration**: Important configuration settings include:
|
||||
- - **outputDirectory**: Specifies the destination directory where the project's JAR file will be placed, typically
|
||||
within the build directory under /modules.
|
||||
- - **artifactItems**: A list detailing the specific project artifacts to copy. This includes:
|
||||
- - - **groupId, artifactId, version, and type**: These attributes uniquely identify the project artifact within the Maven
|
||||
repository, ensuring the correct file is selected.
|
||||
- - - **destFileName**: Specifies the name of the file as it should appear in the output directory. This allows for
|
||||
customization of the output filename, which can be particularly useful in maintaining version control or distinguishing
|
||||
between different builds.
|
||||
- - **overWriteIfNewer**: Ensures that an existing file is only overwritten if the new file is more recent, which helps
|
||||
in managing multiple versions and ensuring that the deployment always uses the most up-to-date artifact.
|
||||
|
||||
This setup ensures that the project artifact is correctly copied to the appropriate location, maintaining the integrity and readiness of the application for deployment. It provides a robust mechanism for managing the artifacts in a build pipeline, aligning with best practices for continuous integration and delivery.
|
||||
|
||||
### jpackage-maven-plugin
|
||||
|
||||
```xml
|
||||
<plugin>
|
||||
<groupId>com.github.akman</groupId>
|
||||
<artifactId>jpackage-maven-plugin</artifactId>
|
||||
<version>${jpackage.maven.plugin}</version>
|
||||
<configuration>
|
||||
<name>${appName}</name>
|
||||
<type>IMAGE</type>
|
||||
<mainclass>${main.class}</mainclass>
|
||||
<input>${project.build.directory}/modules</input>
|
||||
<mainjar>${jar.filename}.jar</mainjar>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>install</phase>
|
||||
<goals>
|
||||
<goal>jpackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
```
|
||||
The jpackage-maven-plugin facilitates the creation of a self-contained application image using Java's JPackage
|
||||
tool, which is part of the JDK. This plugin is configured to run during the 'install' phase of the Maven build
|
||||
lifecycle. It bundles the application along with its dependencies and the Java runtime into a platform-specific
|
||||
package, making it easier to distribute and deploy.
|
||||
|
||||
Key configurations for this plugin include:
|
||||
|
||||
- **Name and Type**: Specifies the application's name and sets the package type to 'IMAGE', indicating a standalone
|
||||
installation image is created.
|
||||
- **Main Class**: Sets the entry point of the application, which is the fully qualified name of the main class.
|
||||
- **Input Directory**: Points to the directory containing the compiled modules and dependencies.
|
||||
- **Main JAR**: Specifies the main executable JAR file of the application.
|
||||
|
||||
This setup is particularly useful for creating a smooth, streamlined deployment process for JavaFX applications,
|
||||
enhancing portability and ease of installation across different environments.
|
||||
@@ -0,0 +1,70 @@
|
||||
# Explanation of the Maven Project file (pom.xml)
|
||||
|
||||
The Maven Project is described inside a XML document which describes the Project Object Model (pom).
|
||||
|
||||
## Start of the pom.xml
|
||||
The first line defines the format and encoding of the file:
|
||||
```
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
```
|
||||
|
||||
The top node (+ modelVersion node) of the XML document is the project node should currently always be:
|
||||
```xml
|
||||
|
||||
<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>
|
||||
|
||||
</project>
|
||||
```
|
||||
|
||||
Maybe in the future the maven project will change the project object model in which case we might want to update
|
||||
the given xsd and modelVersion.
|
||||
|
||||
## Unique identification of project
|
||||
|
||||
Each project should identify itself using a groupId, artefactId and version
|
||||
```xml
|
||||
<groupId>de.kneitzel</groupId>
|
||||
<artifactId>javafxapp</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
```
|
||||
**Important**: You should change these values to something that is unique to you (and your organisation) so
|
||||
that there will never be two projects with the same identification.
|
||||
|
||||
**Optional**: You can name your organization if you want to.
|
||||
```xml
|
||||
<organization>
|
||||
<name>Java Forum</name>
|
||||
</organization>
|
||||
```
|
||||
**Please** remove these lines or change them to your organization.
|
||||
|
||||
## Properties
|
||||
|
||||
Properties are like variables which could be used to have everything, that is quite likely to change, in one location.
|
||||
|
||||
In my project, I grouped the properties in multiple areas:
|
||||
|
||||
### Application specific properties
|
||||
In this group I specify everything that is application specific: What names should be used?
|
||||
Which class is the main class? And so on.
|
||||
|
||||
### Dependency versions
|
||||
All versions of dependencies are stored in this area. That way it is easy to use one version multiple times
|
||||
and it is easay to change these
|
||||
|
||||
### Plugin versions
|
||||
All plugin versions are stored in this area.
|
||||
|
||||
### Other properties
|
||||
Everything that does not fit in the other areas is placed in here e.g. encoding of files.
|
||||
|
||||
The next big areas does not need to be changed to start with the project. Of course: You might want to add dependencies
|
||||
or other plugins later during development.
|
||||
|
||||
The following blocks will be described in detail later:
|
||||
- **dependencies** with a list of all dependencies.
|
||||
- **build/plugins** with all plugins used by this project, including their configuration.
|
||||
- **profiles** We are using a profile. That way, we do not build the image every time we build the project.
|
||||
@@ -0,0 +1,29 @@
|
||||
# Quick Start
|
||||
|
||||
- Simply download a zip file of this project and unzip it somewhere on your computer
|
||||
- open the pom.xml and change the settings at the start of the document to fit with your project
|
||||
|
||||
## How to use this project
|
||||
|
||||
### Clean up
|
||||
|
||||
To clean up the project, call
|
||||
```./mvnw clean```
|
||||
|
||||
### build the application (Without building the application image)
|
||||
|
||||
To build the application, maven / the maven wrapper can be used. Simply do a
|
||||
```./mvnw package```
|
||||
to build the application.
|
||||
(simply call mvnw instead of ./mvnw on windows!)
|
||||
|
||||
### Build the Image
|
||||
|
||||
To build the image, the profile Image must be used:
|
||||
```./mvnw -DImage install```
|
||||
|
||||
## Static code analysis results
|
||||
|
||||
The static code analysis is done during the build of the application. The results can be found in
|
||||
- ./target/pmd.xml
|
||||
- ./target/spotbugsXml.xml
|
||||
@@ -0,0 +1,15 @@
|
||||
# Documentation Overview
|
||||
|
||||
- [Quick Start](QuickStart.md)
|
||||
|
||||
## Maven Project
|
||||
- [Maven Project Overview](MavenProject.md)
|
||||
- [Image Creation](ImageCreation.md)
|
||||
- Checking of Updates
|
||||
|
||||
## Static Code Analysis
|
||||
- PMD
|
||||
- FindBugs
|
||||
|
||||
## Other Topics
|
||||
- Lombok
|
||||
Reference in New Issue
Block a user