Skip to content

Commit

Permalink
[WFMP-210] Add module options for passing things like Java Agents to …
Browse files Browse the repository at this point in the history
…JBoss Modules.

Signed-off-by: James R. Perkins <jperkins@redhat.com>
  • Loading branch information
jamezp committed Jul 7, 2023
1 parent fae2afe commit 525e110
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public interface PropertyNames {

String JAVA_OPTS = "wildfly.javaOpts";

String MODULE_OPTS = "wildfly.moduleOptions";

String MODULES_PATH = "wildfly.modulesPath";

String OFFLINE = "wildfly.offline";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ public abstract class AbstractServerStartMojo extends AbstractServerConnection {
@Parameter(alias = "java-opts", property = PropertyNames.JAVA_OPTS)
private String[] javaOpts;

/**
* Options passed to JBoss Modules. This is useful for things like Java Agents where you need to start the server
* with an agent.
*/
@Parameter(alias = "module-options", property = PropertyNames.MODULE_OPTS)
private String[] moduleOptions;

/**
* The {@code JAVA_HOME} to use for launching the server.
*/
Expand Down Expand Up @@ -303,6 +310,18 @@ public void setJavaOpts(final String value) {
}
}

/**
* Allows the {@link #moduleOptions} to be set as a string. The string is assumed to be space delimited.
*
* @param value a spaced delimited value of JBoss Modules options
*/
@SuppressWarnings("unused")
public void setModulesOptions(final String value) {
if (value != null) {
moduleOptions = value.split("\\s+");
}
}

protected StandaloneCommandBuilder createStandaloneCommandBuilder(final Path jbossHome, final String serverConfig)
throws MojoExecutionException {
final StandaloneCommandBuilder commandBuilder = StandaloneCommandBuilder.of(jbossHome)
Expand Down Expand Up @@ -330,6 +349,10 @@ protected StandaloneCommandBuilder createStandaloneCommandBuilder(final Path jbo
commandBuilder.addServerArguments(serverArgs);
}

if (Utils.isNotNullOrEmpty(moduleOptions)) {
commandBuilder.setModuleOptions(moduleOptions);
}

final Path javaHomePath = (this.javaHome == null ? Paths.get(System.getProperty("java.home"))
: Paths.get(this.javaHome));
if (Environment.isModularJvm(javaHomePath)) {
Expand Down

0 comments on commit 525e110

Please sign in to comment.