10 Commits
11 changed files with 194 additions and 56 deletions
+1
View File
@@ -16,3 +16,4 @@ target
debug.out debug.out
.DS_Store .DS_Store
dependency-reduced-pom.xml
+1 -1
View File
@@ -14,5 +14,5 @@
# KIND, either express or implied. See the License for the # KIND, either express or implied. See the License for the
# specific language governing permissions and limitations # specific language governing permissions and limitations
# under the License. # under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.6/apache-maven-3.8.6-bin.zip distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.11/apache-maven-3.9.11-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
+5
View File
@@ -33,6 +33,11 @@ Um das Image mit NativeImage / GraalVM zu bauen, rufst du einfach Maven mit dem
Ziel install auf: Ziel install auf:
```./mvnw -Dnative install``` ```./mvnw -Dnative install```
## Bau einer fat jar Datei
Über das Profil fatjar läßt sich auch ein fat jar File bauen, welches alle Abhängigkeiten enthält.
```./mvnw -Dimage install```
## Ergebnisse der statischen Codeanalyse ## Ergebnisse der statischen Codeanalyse
Die Codeanalyse läuft automatisch beim Bau des Projektes und die Ergebnisse Die Codeanalyse läuft automatisch beim Bau des Projektes und die Ergebnisse
+3 -1
View File
@@ -13,4 +13,6 @@
## Sonstiges ## Sonstiges
- Reporting - Reporting
- Lombok - Lombok
## [Fragen und Antworten](qa.md)
+4
View File
@@ -0,0 +1,4 @@
# Fragen und Antworten
+5
View File
@@ -27,6 +27,11 @@ To build the image with jpackage, the profile image must be used:
To build the native image with GraalVM, the profile native must be used: To build the native image with GraalVM, the profile native must be used:
```./mvnw -Dnative install``` ```./mvnw -Dnative install```
### Build a fat jar file
You can build a fat jar file using the fatjar Image:
```./mvnw -Dfatjar package```
## Static code analysis results ## Static code analysis results
The static code analysis is done during the build of the application. The results can be found in The static code analysis is done during the build of the application. The results can be found in
+3 -1
View File
@@ -13,4 +13,6 @@
## Other Topics ## Other Topics
- Reporting - Reporting
- Lombok - Lombok
## [Questions and Answers](qa.md)
+2
View File
@@ -0,0 +1,2 @@
# Questions and Answers
+126 -34
View File
@@ -7,7 +7,7 @@
<!-- Edit these to match your project --> <!-- Edit these to match your project -->
<groupId>de.kneitzel</groupId> <groupId>de.kneitzel</groupId>
<artifactId>javamavenapp</artifactId> <artifactId>javamavenapp</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
@@ -24,35 +24,36 @@
<launcher>${project.artifactId}</launcher> <launcher>${project.artifactId}</launcher>
<appName>${project.artifactId}</appName> <appName>${project.artifactId}</appName>
<main.class>de.kneitzel.JavaApp</main.class> <main.class>de.kneitzel.JavaApp</main.class>
<java.version>21</java.version> <java.version>25</java.version>
<jar.filename>${project.artifactId}-${project.version}</jar.filename> <jar.filename>${project.artifactId}-${project.version}</jar.filename>
<!-- Dependency versions --> <!-- Dependency versions -->
<jetbrains.annotations.version>24.1.0</jetbrains.annotations.version> <jetbrains.annotations.version>26.0.2-1</jetbrains.annotations.version>
<junit.version>5.10.2</junit.version> <junit.version>6.0.1</junit.version>
<lombok.version>1.18.32</lombok.version> <lombok.version>1.18.42</lombok.version>
<mockito.version>5.11.0</mockito.version> <mockito.version>5.20.0</mockito.version>
<spotbugs.version>4.8.5</spotbugs.version> <spotbugs.version>4.9.8</spotbugs.version>
<!-- Plugin dependencies --> <!-- Plugin dependencies -->
<codehaus.version.plugin>2.16.2</codehaus.version.plugin> <codehaus.version.plugin>2.20.1</codehaus.version.plugin>
<jpackage.maven.plugin>0.1.5</jpackage.maven.plugin> <jpackage.maven.plugin>0.1.5</jpackage.maven.plugin>
<maven.clean.plugin>3.3.2</maven.clean.plugin> <maven.clean.plugin>3.5.0</maven.clean.plugin>
<maven.compiler.plugin>3.13.0</maven.compiler.plugin> <maven.compiler.plugin>3.14.1</maven.compiler.plugin>
<maven.dependency.plugin>3.6.1</maven.dependency.plugin> <maven.dependency.plugin>3.9.0</maven.dependency.plugin>
<maven.deploy.plugin>3.1.2</maven.deploy.plugin> <maven.deploy.plugin>3.1.4</maven.deploy.plugin>
<maven.enforcer.plugin>3.4.1</maven.enforcer.plugin> <maven.enforcer.plugin>3.6.2</maven.enforcer.plugin>
<maven.install.plugin>3.1.2</maven.install.plugin> <maven.install.plugin>3.1.4</maven.install.plugin>
<maven.jar.plugin>3.4.1</maven.jar.plugin> <maven.jar.plugin>3.5.0</maven.jar.plugin>
<maven.javadoc.plugin>3.6.3</maven.javadoc.plugin> <maven.javadoc.plugin>3.12.0</maven.javadoc.plugin>
<maven.pmd.plugin>3.22.0</maven.pmd.plugin> <maven.pmd.plugin>3.28.0</maven.pmd.plugin>
<maven.project.info.reports.plugin>3.5.0</maven.project.info.reports.plugin> <maven.project.info.reports.plugin>3.9.0</maven.project.info.reports.plugin>
<maven.resources.plugin>3.3.1</maven.resources.plugin> <maven.resources.plugin>3.4.0</maven.resources.plugin>
<maven.site.plugin>4.0.0-M14</maven.site.plugin> <maven.shade.plugin>3.6.1</maven.shade.plugin>
<maven.surfire.plugin>3.2.5</maven.surfire.plugin> <maven.site.plugin>4.0.0-M16</maven.site.plugin>
<maven.surfire.plugin>3.5.4</maven.surfire.plugin>
<moditect.maven.plugin>1.0.0.RC2</moditect.maven.plugin> <moditect.maven.plugin>1.0.0.RC2</moditect.maven.plugin>
<native.maven.plugin>0.10.1</native.maven.plugin> <native.maven.plugin>0.11.3</native.maven.plugin>
<spotbugs.maven.plugin>4.8.5.0</spotbugs.maven.plugin> <spotbugs.maven.plugin>4.9.8.2</spotbugs.maven.plugin>
<!-- other properties --> <!-- other properties -->
<pmd.target>pmd</pmd.target> <!-- Set to 'pmd' if pmd should not fail on issues. Set to 'check' if you want build to fail when issues found --> <pmd.target>pmd</pmd.target> <!-- Set to 'pmd' if pmd should not fail on issues. Set to 'check' if you want build to fail when issues found -->
@@ -141,16 +142,6 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin}</version> <version>${maven.compiler.plugin}</version>
<configuration>
<release>${java.version}</release>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin> </plugin>
<!--Test execution --> <!--Test execution -->
@@ -250,11 +241,43 @@
<version>${maven.install.plugin}</version> <version>${maven.install.plugin}</version>
</plugin> </plugin>
<!-- jar plugin - to remove the warning regarding version --> <!-- jar plugin - set man class and classpath -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.plugin}</version> <version>${maven.jar.plugin}</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>${main.class}</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- dependency plugin - copy dependencies to lib folder. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>${maven.dependency.plugin}</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
</configuration>
</execution>
</executions>
</plugin> </plugin>
<!-- resources plugin - to remove the warning regarding version --> <!-- resources plugin - to remove the warning regarding version -->
@@ -483,6 +506,75 @@
</build> </build>
</profile> </profile>
<!-- Profile to build a fat jar
Add -Pfatjar or -Dfatjar to use this profile.
-->
<profile>
<id>fatjar</id>
<activation>
<property>
<name>fatjar</name>
</property>
</activation>
<build>
<plugins>
<!-- Set jar plugin to not set classpath -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.jar.plugin}</version>
<configuration>
<archive>
<manifest>
<addClasspath>false</addClasspath>
</manifest>
</archive>
</configuration>
</plugin>
<!-- build the fat jar -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven.shade.plugin}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>full</shadedClassifierName>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<manifestEntries>
<Main-Class>${main.class}</Main-Class>
<Build-Version>1.0</Build-Version>
</manifestEntries>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
<exclude>**/module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles> </profiles>
</project> </project>
+22 -13
View File
@@ -2,51 +2,60 @@ package de.kneitzel;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Simple Greeting class for some demonstration. * Simple greeting value object used for demonstration purposes.
*
* <p>Instances are immutable and encapsulate a single name that is used when generating
* a greeting string via {@link #toString()}.
*/ */
public class Greeting { public class Greeting {
/** /**
* Default name that should be greeted if no name is given. * Default name used when no explicit name is provided. The default value is the German
* word {@code "Welt"} ("world").
*/ */
public static final String DEFAULT_NAME = "Welt"; public static final String DEFAULT_NAME = "Welt";
/** /**
* Name that should be greeted * The name to greet. Never {@code null}.
* <p>
* Cannot be null.
* </p>
*/ */
@NotNull @NotNull
private final String name; private final String name;
/** /**
* Gets the name that should be greeted. * Returns the name that will be greeted.
* @return Name that should be greeted. *
* @return the name to greet; never {@code null}.
*/ */
public @NotNull String getName() { public @NotNull String getName() {
return name; return name;
} }
/** /**
* Creates a new Instance of Greeting which greets the "World". * Creates a new {@code Greeting} instance that greets the default name ({@link #DEFAULT_NAME}).
*/ */
public Greeting() { public Greeting() {
this(null); this(null);
} }
/** /**
* Creates a new instance of Greeting to greet the given name. * Creates a new {@code Greeting} instance for the given name.
* @param name Name that should be greeted by Greeting. *
* @param name the name to greet; may be {@code null} in which case {@link #DEFAULT_NAME}
* will be used instead.
*/ */
public Greeting(@Nullable final String name) { public Greeting(@Nullable final String name) {
this.name = name == null ? DEFAULT_NAME : name; this.name = name == null ? DEFAULT_NAME : name;
} }
/** /**
* String representation of this instance. * Returns a greeting string for this instance.
* @return String representation of "Hello name!" *
* <p>The greeting is formatted in German as {@code "Hallo <name>!"}. The returned string is
* never {@code null}.
*
* @return a greeting such as {@code "Hallo Welt!"}; never {@code null}.
*/ */
@NotNull @NotNull
@Override @Override
+22 -6
View File
@@ -1,23 +1,39 @@
package de.kneitzel; package de.kneitzel;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.Objects;
/** /**
* Starting point of the JavaApp * Entry point for the JavaMavenApp application.
*
* <p>This final utility class is not instantiable and provides the application's main method.
* It coordinates startup behavior and is responsible for high-level program initialization.
*
* @since 1.0
*/ */
public final class JavaApp { public final class JavaApp {
/** /**
* Private Constructor - we never create an instance! * Private constructor to prevent instantiation of this utility class.
*
* <p>The class only exposes static behavior and should never be instantiated.
*/ */
private JavaApp() {} private JavaApp() {}
/** /**
* Entry point of the application. * Application entry point.
* @param args Commandline parameters. *
* <p>This method initializes a {@code Greeting} instance and writes its string representation
* to standard output. The method does not parse or use {@code args} currently; they are
* preserved for future extensions.
*
* @param args the command-line arguments supplied to the application; must not be {@code null}.
* Currently unused and preserved for future extensions.
*/ */
public static void main(@NotNull final String[] args) { static void main(@NotNull final String[] args) {
// Validate the parameter and reference it to avoid unused-parameter inspections.
Objects.requireNonNull(args, "args must not be null");
final Greeting greeting = new Greeting(null); final Greeting greeting = new Greeting(null);
System.out.println(greeting); System.out.println(greeting);
} }