Skip to content

Commit 157e839

Browse files
committed
Add jvm arguments for maven plugin
1 parent 10d348b commit 157e839

8 files changed

Lines changed: 52 additions & 17 deletions

File tree

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,13 +560,15 @@ The plugin provides the following goals:
560560
* `update` — intended for development purposes. It updates the repository with the specified modules in an existing
561561
distribution, avoiding full reassembly on every change. The execution is skipped if the specified `path` doesn't exist.
562562

563-
Common parameters for `assemble-runtime` and `assemble-dist`:
563+
Common configuration parameters for `assemble-runtime` and `assemble-dist` goals:
564564

565565
| Parameter | Required | Default | Description |
566566
|-----------|----------|---------|-------------|
567567
| `path` | Yes | - | Path to the root framework directory where the runtime/distribution will be assembled |
568568
| `components` | Yes | - | The list of components that will be added to the runtime/distribution |
569+
| `components/component` | Yes | - | The component that will be added to the runtime/distribution |
569570
| `modules` | No | - | The list of additional JPMS modules to resolve and include in the repository in addition to the minimal set of required modules. |
571+
| `modules/module` | Yes | - | The JPMS module to resolve and include in the repository in addition to the minimal set of required modules. |
570572
| `module/groupId` | Yes | - | Module group ID |
571573
| `module/artifactId` | Yes | - | Module artifact ID |
572574
| `module/version` | Yes | - | Module version |
@@ -579,14 +581,17 @@ Additional configuration parameters for the `assemble-dist` goal:
579581
|-----------|----------|---------|-------------|
580582
| `mainClass` | Yes | - | Main class in the format `module/fully.qualified.ClassName`, used only in `.sh`/`.bat` scripts|
581583
| `scriptName` | No | `framework` | The name of the `.sh`/`.bat` scripts|
584+
| `jvmArgs` | No | - | The JVM arguments used in `.sh`/`.bat` scripts|
585+
| `jvmArgs/jvmArg` | Yes | - | The JVM argument used in `.sh`/`.bat` scripts|
582586
| `module/onModulePath` | No | `false` | If `true`, the module will be added to the `--module-path` in `.sh`/`.bat` scripts |
583587

584-
Parameters for `update` goal:
588+
Configuration parameters for `update` goal:
585589

586590
| Parameter | Required | Default | Description |
587591
|-----------|----------|---------|-------------|
588592
| `path` | Yes | - | Path to the root framework directory where the modules will be updated |
589593
| `modules` | No | - | The list of modules in the repository to update. |
594+
| `modules/module` | Yes | - | The module in the repository to update. |
590595
| `module/groupId` | Yes | - | Module group ID |
591596
| `module/artifactId` | Yes | - | Module artifact ID |
592597
| `module/version` | Yes | - | Module version |
@@ -609,6 +614,9 @@ Example:
609614
<configuration>
610615
<path>${project.build.directory}/framework</path>
611616
<mainClass>com.myapp/com.myapp.Main</mainClass>
617+
<jvmArgs>
618+
<jvmArg>-agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n</jvmArg>
619+
</jvmArgs>
612620
<components>
613621
<component>weaverbird-repo</component>
614622
</components>

weaverbird-assembly/weaverbird-assembly-maven-plugin/src/main/java/com/techsenger/weaverbird/assembly/maven/plugin/AssembleDistMojo.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.nio.charset.StandardCharsets;
2222
import java.nio.file.Files;
2323
import java.nio.file.Path;
24+
import java.util.List;
2425
import java.util.Properties;
2526
import java.util.regex.Pattern;
2627
import org.apache.maven.plugin.MojoExecutionException;
@@ -42,6 +43,9 @@ public class AssembleDistMojo extends AbstractAssembleMojo {
4243
@Parameter(required = false, defaultValue = "framework")
4344
private String scriptName;
4445

46+
@Parameter(required = false)
47+
private List<String> jvmArgs;
48+
4549
@Override
4650
public void execute() throws MojoExecutionException, MojoFailureException {
4751
try {
@@ -70,8 +74,8 @@ private void createBin() throws Exception {
7074
shModulePath += "MODULE_PATH=\"$MODULE_PATH:$REPO_PATH" + resolvePath(artifact, false) + "\"" + s;
7175
batModulePath += "set \"MODULE_PATH=!MODULE_PATH!%REPO_PATH%" + resolvePath(artifact, true) + ";\"" + s;
7276
}
73-
createOsScript(shModulePath, ".sh", binPath);
74-
createOsScript(batModulePath, ".bat", binPath);
77+
createOsScript(shModulePath, ".sh", " \\", binPath);
78+
createOsScript(batModulePath, ".bat", " ^", binPath);
7579
}
7680

7781
private void addLoggerConfig() throws Exception {
@@ -80,10 +84,22 @@ private void addLoggerConfig() throws Exception {
8084
FileUtils.writeFile(config.resolve("log4j2.xml"), logConfigContent, StandardCharsets.UTF_8);
8185
}
8286

83-
private void createOsScript(String modulePath, String ext, Path binPath) throws Exception {
87+
private void createOsScript(String modulePath, String ext, String jvmArgSep, Path binPath) throws Exception {
8488
var properties = new Properties();
8589
properties.put("modulepath", modulePath);
8690
properties.put("mainClass", mainClass);
91+
if (jvmArgs != null) {
92+
StringBuilder builder = new StringBuilder();
93+
for (var arg : jvmArgs) {
94+
if (builder.length() > 0) {
95+
builder.append("\n");
96+
}
97+
builder.append(" ");
98+
builder.append(arg);
99+
builder.append(jvmArgSep);
100+
}
101+
properties.put("jvmArgs", builder.toString());
102+
}
87103
var shContent = String.join(System.lineSeparator(), readFile("framework" + ext));
88104
shContent = interpolate(shContent, properties);
89105
var shPath = binPath.resolve(scriptName + ext);

weaverbird-assembly/weaverbird-assembly-maven-plugin/src/main/resources/com/techsenger/weaverbird/assembly/maven/plugin/framework.bat

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@ ${modulepath}
1717
::# #
1818
::#########################################################################################
1919

20-
java -agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n ^
21-
-Dorg.jboss.logging.provider=log4j ^
22-
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager ^
23-
-Dlog4j.configurationFile=%ROOT_PATH%\config\log4j2.xml ^
20+
java ^
2421
-Dcom.techsenger.weaverbird.core.root.path=%ROOT_PATH% ^
25-
-Djava.net.preferIPv4Stack=true ^
22+
-Dlog4j.configurationFile=%ROOT_PATH%\config\log4j2.xml ^
23+
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager ^
24+
-Dorg.jboss.logging.provider=log4j ^
2625
-Djava.io.tmpdir=%ROOT_PATH%\temp ^
2726
-Dfile.encoding=UTF-8 ^
28-
-Djavafx.enablePreview=true ^
27+
${jvmArgs}
2928
--add-modules ALL-DEFAULT ^
3029
--add-modules org.apache.logging.log4j,org.apache.logging.log4j.jul ^
3130
--add-opens java.base/java.time=com.techsenger.weaverbird.core ^

weaverbird-assembly/weaverbird-assembly-maven-plugin/src/main/resources/com/techsenger/weaverbird/assembly/maven/plugin/framework.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ ${modulepath}
1818
# #
1919
#########################################################################################
2020

21-
java -agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n \
22-
-Dorg.jboss.logging.provider=log4j \
23-
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
24-
-Dlog4j.configurationFile="$ROOT_PATH/config/log4j2.xml" \
21+
java \
2522
-Dcom.techsenger.weaverbird.core.root.path="$ROOT_PATH" \
26-
-Djava.net.preferIPv4Stack=true \
23+
-Dlog4j.configurationFile="$ROOT_PATH/config/log4j2.xml" \
24+
-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager \
25+
-Dorg.jboss.logging.provider=log4j \
2726
-Djava.io.tmpdir="$ROOT_PATH/temp" \
2827
-Dfile.encoding=UTF-8 \
29-
-Djavafx.enablePreview=true \
28+
${jvmArgs}
3029
--add-modules ALL-DEFAULT \
3130
--add-modules org.apache.logging.log4j,org.apache.logging.log4j.jul \
3231
--add-opens java.base/java.time=com.techsenger.weaverbird.core \

weaverbird-demo/weaverbird-demo-cli/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
<configuration>
5656
<path>${project.build.directory}/framework</path>
5757
<mainClass>com.techsenger.weaverbird.demo.cli/com.techsenger.weaverbird.demo.cli.CliDemo</mainClass>
58+
<jvmArgs>
59+
<jvmArg>-agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n</jvmArg>
60+
</jvmArgs>
5861
<components>
5962
<component>weaverbird-repo</component>
6063
<component>weaverbird-server</component>

weaverbird-demo/weaverbird-demo-gui/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
<configuration>
5858
<path>${project.build.directory}/framework</path>
5959
<mainClass>com.techsenger.weaverbird.demo.gui/com.techsenger.weaverbird.demo.gui.GuiDemo</mainClass>
60+
<jvmArgs>
61+
<jvmArg>-agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n</jvmArg>
62+
<jvmArg>-Djavafx.enablePreview=true</jvmArg>
63+
</jvmArgs>
6064
<components>
6165
<component>weaverbird-repo</component>
6266
<component>weaverbird-server</component>

weaverbird-demo/weaverbird-demo-jfx/weaverbird-demo-jfx-boot/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@
4848
<configuration>
4949
<path>${project.build.directory}/framework</path>
5050
<mainClass>com.techsenger.weaverbird.demo.jfx.boot/com.techsenger.weaverbird.demo.jfx.boot.JfxDemo</mainClass>
51+
<jvmArgs>
52+
<jvmArg>-agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n</jvmArg>
53+
</jvmArgs>
5154
<components>
5255
<component>weaverbird-repo</component>
5356
<component>weaverbird-server</component>

weaverbird-demo/weaverbird-demo-starter/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
<configuration>
4444
<path>${project.build.directory}/framework</path>
4545
<mainClass>com.techsenger.weaverbird.demo.starter/com.techsenger.weaverbird.demo.starter.StarterDemo</mainClass>
46+
<jvmArgs>
47+
<jvmArg>-agentlib:jdwp=transport=dt_socket,address=7700,server=y,suspend=n</jvmArg>
48+
</jvmArgs>
4649
<components>
4750
<component>weaverbird-repo</component>
4851
</components>

0 commit comments

Comments
 (0)