Skip to content

Commit

Permalink
Fix documentation formatting, add menu items for new examples
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Jan 28, 2024
1 parent 1d90140 commit bf6a0f1
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 45 deletions.
8 changes: 4 additions & 4 deletions src/site/apt/examples/example-exec-for-java-programs.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ mvn exec:exec -Dexec.executable="java" [...] -Dexec.args="%classpath"

To execute Java programs, the Exec Maven Plugin helps by allowing the <<<\<classpath\>>>> special argument:

-------------------
+-------------------+
<configuration>
<executable>java</executable>
<arguments>
Expand Down Expand Up @@ -79,11 +79,11 @@ mvn exec:exec -Dexec.executable="java" [...] -Dexec.args="%classpath"
...
</arguments>
</configuration>
-------------------
+-------------------+

In case of the modules as supported since Java9 the configuration looks like

-------------------
+-------------------+
<configuration>
<executable>java</executable>
<arguments>
Expand All @@ -96,4 +96,4 @@ In case of the modules as supported since Java9 the configuration looks like
...
</arguments>
</configuration>
-------------------
+-------------------+
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ Changing the classpath scope when running Java programs
to change the scope of the plugin execution. This can be achieved using the <<<classpathScope>>> configuration element,
e.g. for a <<<test>>> scope:

-------------------
+-------------------+
<configuration>
...
<classpathScope>test</classpathScope>
...
</configuration>
-------------------
+-------------------+

or, on the command line,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Using Executable Binary Dependencies Instead of Local Executables

** pom.xml

-------------------
+-------------------+
<project>
...
<build>
Expand Down Expand Up @@ -71,4 +71,4 @@ Using Executable Binary Dependencies Instead of Local Executables
</build>
...
</project>
-------------------
+-------------------+
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Using Plugin Dependencies Instead of Project Dependencies

* Example POM Configuration using Plugin Dependencies

-------------------
+-------------------+
<project>
...
<build>
Expand Down Expand Up @@ -104,4 +104,4 @@ Using Plugin Dependencies Instead of Project Dependencies
</build>
...
</project>
-------------------
+-------------------+
24 changes: 12 additions & 12 deletions src/site/apt/examples/example-exec-using-toolchains.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Using Toolchains Instead of Explicit Paths

** pom.xml

-------------------
+-------------------+
<project>
...
<build>
Expand Down Expand Up @@ -80,11 +80,11 @@ Using Toolchains Instead of Explicit Paths
</build>
...
</project>
-------------------
+-------------------+

** toolchains.xml

-------------------
+-------------------+
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
Expand All @@ -102,7 +102,7 @@ Using Toolchains Instead of Explicit Paths
</toolchain>
...
</toolchains>
-------------------
+-------------------+

* The "jdk" Toolchain

Expand All @@ -111,7 +111,7 @@ Using Toolchains Instead of Explicit Paths

** pom.xml

-------------------
+-------------------+
<project>
...
<build>
Expand Down Expand Up @@ -145,11 +145,11 @@ Using Toolchains Instead of Explicit Paths
</build>
...
</project>
-------------------
+-------------------+

** toolchains.xml

-------------------
+-------------------+
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
Expand All @@ -166,7 +166,7 @@ Using Toolchains Instead of Explicit Paths
</toolchain>
...
</toolchains>
-------------------
+-------------------+

* Custom Toolchains

Expand All @@ -176,7 +176,7 @@ Using Toolchains Instead of Explicit Paths

** pom.xml

-------------------
+-------------------+
<project>
...
<build>
Expand Down Expand Up @@ -217,11 +217,11 @@ Using Toolchains Instead of Explicit Paths
</build>
...
</project>
-------------------
+-------------------+

** toolchains.xml

-------------------
+-------------------+
<?xml version="1.0" encoding="UTF8"?>
<toolchains>
<toolchain>
Expand All @@ -235,4 +235,4 @@ Using Toolchains Instead of Explicit Paths
</toolchain>
...
</toolchains>
-------------------
+-------------------+
10 changes: 5 additions & 5 deletions src/site/apt/examples/example-java-project-properties.apt.vm
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html

Forward maven properties to exec:java goal

You can ensure the maven properties are available to your main forcing `<projectProperties />` property type.
You can ensure the maven properties are available to your main forcing <<<\<projectProperties /\>>>> property type.

Tip: you can still override potentially conflicting properties if you set them *after*.
Tip: you can still override potentially conflicting properties if you set them <<after>>.

* pom.xml

-------------------
+-------------------+
<project>
...
<build>
Expand Down Expand Up @@ -67,5 +68,4 @@ You can ensure the maven properties are available to your main forcing `<project
</build>
...
</project>
-------------------

+-------------------+
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
------
Use Runnable with exec:java goal
Execute a Runnable instead of a main
------
Romain Manni-Bucau
------
2022-11-14
2024-01-27
------

~~ Copyright 2022 The Codehaus
~~ Copyright 2024 The Codehaus
~~
~~ Licensed under the Apache License, Version 2.0 (the "License");
~~ you may not use this file except in compliance with the License.
Expand All @@ -23,12 +23,13 @@
~~ NOTE: For help with the syntax of this file, see:
~~ http://maven.apache.org/doxia/references/apt-format.html

Execute a Runnable instead of a main

You can use since version `3.1.2` a `Runnable` instead of providing a main class to `exec:java`:
You can use since version <<<3.2.0>>> a <<<Runnable>>> instead of providing a main class to <<<exec:java>>>:

* pom.xml

-------------------
+-------------------+
<project>
...
<build>
Expand All @@ -54,25 +55,33 @@ You can use since version `3.1.2` a `Runnable` instead of providing a main class
</build>
...
</project>
-------------------
+-------------------+

The Runnable can be a plain class but can also get constructor injections:

* `systemProperties`: `Properties`, session system properties
* `systemPropertiesUpdater`: `BiConsumer&lt;String, String&gt;`, session system properties update callback (pass the key/value to update, null value means removal of the key)
* `userProperties`: `Properties`, session user properties
* `userPropertiesUpdater`: `BiConsumer&lt;String, String&gt;`, session user properties update callback (pass the key/value to update, null value means removal of the key)
* `projectProperties`: `Properties`, project properties
* `projectPropertiesUpdater`: `BiConsumer&lt;String, String&gt;`, project properties update callback (pass the key/value to update, null value means removal of the key)
* `highestVersionResolver`: `Function&lt;String, String&gt;`, passing a `groupId:artifactId` you get the latest resolved version from the project repositories.
* <<<systemProperties>>>: <<<Properties>>>, session system properties

Lastly you can inject a custom maven component naming the Runnable constructor parameter with its type and replacing dots by underscores.
If you need to provide a hint you can suffix previous type name by `__hint_$yourhint` (assuming it stays a valid java name).
This kind of parameter injection must be typed `Object`.
* <<<systemPropertiesUpdate>>>: <<<BiConsumer\<String, String\>>>>, session system properties update callback (pass the key/value to update, null value means removal of the key)

* <<<userProperties>>>: <<<Properties>>>, session user properties

* <<<userPropertiesUpdater>>>: <<<BiConsumer\<String, String\>>>>, session user properties update callback (pass the key/value to update, null value means removal of the key)

* <<<projectProperties>>>: <<<Properties>>>, project properties

* <<<projectPropertiesUpdater>>>: <<<BiConsumer\<String, String\>>>>, project properties update callback (pass the key/value to update, null value means removal of the key)

* <<<highestVersionResolver>>>: <<<Function\<String, String\>>>>, passing a <<<groupId:artifactId>>> you get the latest resolved version from the project repositories.

[]

Lastly you can inject a custom maven component naming the Runnable constructor parameter with its type and replacing dots by underscores.
If you need to provide a hint you can suffix previous type name by <<<__hint_$yourhint>>> (assuming it stays a valid java name).
This kind of parameter injection must be typed `Object`.

Example:

-------------------
+-------------------+
public class HelloRunnable implements Runnable {
private final Function<String, String> versionResolver;
private final Properties properties;
Expand All @@ -92,4 +101,4 @@ public class HelloRunnable implements Runnable {
updater.accept("hello.runnable.output", v + ": " + (versionResolver != null));
}
}
-------------------
+-------------------+
4 changes: 4 additions & 0 deletions src/site/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
href="examples/example-exec-using-toolchains.html"/>
<item name="Using executable binary dependencies instead of local executables"
href="examples/example-exec-using-executabledependency.html"/>
<item name="Forward maven system properties to the main"
href="examples/example-java-project-properties.html"/>
<item name="Execute a Runnable instead of a main"
href="examples/example-java-runnable.html"/>
</menu>
</body>
</project>

0 comments on commit bf6a0f1

Please sign in to comment.