From 635fce80b8facc3a755a97d53efa0b2297700979 Mon Sep 17 00:00:00 2001 From: Martin Goik <goik@hdm-stuttgart.de> Date: Sat, 17 Dec 2022 23:05:28 +0100 Subject: [PATCH] maven execution samples --- .../META-INF/maven/archetype-metadata.xml | 6 +++ .../resources/archetype-resources/Readme.md | 54 +++++++++++++++++-- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml b/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml index 6948a1804..f86d9effa 100644 --- a/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -9,6 +9,12 @@ <include>**/*.java</include> </includes> </fileSet> + <fileSet filtered="true" encoding="UTF-8"> + <directory/> + <includes> + <include>Readme.md</include> + </includes> + </fileSet> <fileSet filtered="true" encoding="UTF-8"> <directory>src/main/resources</directory> <includes> diff --git a/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/archetype-resources/Readme.md b/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/archetype-resources/Readme.md index c6f34af1a..df24c04d9 100644 --- a/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/archetype-resources/Readme.md +++ b/ws/Archetypes/mi-maven-archetype-quickstart/src/main/resources/archetype-resources/Readme.md @@ -15,10 +15,11 @@ providing the following updates / enhancements: ## Prerequisites -This archetype is available from [HdM / MI](https://maven.mi.hdm-stuttgart.de) to Maven by configuring -a file `~/.m2/settings.xml` with `~` denoting your home folder: +This archetype is available from [HdM / MI](https://maven.mi.hdm-stuttgart.de/nexus/service/rest/repository/browse/mi-maven/de/hdm_stuttgart/mi/mi-maven-archetype-quickstart/2.2) +to be used by Maven. This requires configuring access to the MI Nexus server by editing file `~/.m2/settings.xml` +with `~` denoting your home folder: -``` +```xml <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> @@ -50,14 +51,57 @@ advised to [turn this off](https://www.thewindowsclub.com/show-file-extensions-i ## Usage -Create an new project: +### Create an new project: -``` +```shell mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \ -DartifactId=first -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \ -DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=2.2 ``` +### Generate Javadoc + +```shell +mvn javadoc:javadoc +``` + +The resulting `target/site/apidocs/index.html` entry file may be viewed by any reasonable web browser. + +### Create an executable jar file + +The `pom.xml` contains: + +```xml +... +<manifestEntries> + <Main-Class>$package.App</Main-Class> + <Multi-Release>true</Multi-Release> +</manifestEntries> +... +``` + +`App.java` is supposed to contain a `main(...)` method to be executed. Invoking `mvn package` results in: + +```shell +> mvn clean package +[INFO] Scanning for projects... +... +[INFO] Building jar: /home/goik/tmp/first/target/first-0.9.jar +... +[INFO] Replacing /home/goik/tmp/first/target/first-0.9.jar with /home/goik/tmp/first/target/first-0.9-shaded.jar +... +``` +This generated jar is ready to be executed: + +```shell +> java -jar target/first-0.9.jar +Hi there, + let's have + fun learning Java! +2022-12-17 22:56:34,478 DEBUG [main] sd1.App (App.java:38) - You may configure 'src/main/resources/log4j2.xml' +2022-12-17 22:56:34,480 DEBUG [main] sd1.App (App.java:39) - for adapting both console and 'A1.log' file output +``` + ## Details Three sample classes and one corresponding Junit test class are being provided: -- GitLab