Skip to content
Snippets Groups Projects
Commit 635fce80 authored by Goik Martin's avatar Goik Martin
Browse files

maven execution samples

parent e8c9dab3
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,12 @@ ...@@ -9,6 +9,12 @@
<include>**/*.java</include> <include>**/*.java</include>
</includes> </includes>
</fileSet> </fileSet>
<fileSet filtered="true" encoding="UTF-8">
<directory/>
<includes>
<include>Readme.md</include>
</includes>
</fileSet>
<fileSet filtered="true" encoding="UTF-8"> <fileSet filtered="true" encoding="UTF-8">
<directory>src/main/resources</directory> <directory>src/main/resources</directory>
<includes> <includes>
......
...@@ -15,10 +15,11 @@ providing the following updates / enhancements: ...@@ -15,10 +15,11 @@ providing the following updates / enhancements:
## Prerequisites ## Prerequisites
This archetype is available from [HdM / MI](https://maven.mi.hdm-stuttgart.de) to Maven by configuring 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)
a file `~/.m2/settings.xml` with `~` denoting your home folder: 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" <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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"> 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 ...@@ -50,14 +51,57 @@ advised to [turn this off](https://www.thewindowsclub.com/show-file-extensions-i
## Usage ## Usage
Create an new project: ### Create an new project:
``` ```shell
mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \ mvn --batch-mode -e archetype:generate -DgroupId=de.hdm_stuttgart.mi.sd1 \
-DartifactId=first -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \ -DartifactId=first -Dversion=0.9 -DarchetypeGroupId=de.hdm_stuttgart.mi \
-DarchetypeArtifactId=mi-maven-archetype-quickstart -DarchetypeVersion=2.2 -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 ## Details
Three sample classes and one corresponding Junit test class are being provided: Three sample classes and one corresponding Junit test class are being provided:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment