Skip to content

Commit

Permalink
Merge pull request #357 from jamezp/WFMP-210
Browse files Browse the repository at this point in the history
[WFMP-210] Add module options for passing things like Java Agents to …
  • Loading branch information
jamezp authored Jul 7, 2023
2 parents fae2afe + 525e110 commit 4fed6aa
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 4fed6aa

Please sign in to comment.