Skip to content

Commit

Permalink
Added module-root-dir option to AddModule command
Browse files Browse the repository at this point in the history
  • Loading branch information
honza-kasik authored and simkam committed Oct 7, 2021
1 parent beece4d commit b24378f
Showing 1 changed file with 37 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class AddModule implements OnlineCommand {
private final String moduleName;
private final String slot;
private final String mainClass;
private final String moduleRootDir;
private final String moduleXml;
private final List<String> resources;
private final List<String> dependencies;
Expand All @@ -46,6 +47,7 @@ private AddModule(Builder builder) {
this.moduleName = builder.moduleName;
this.slot = builder.slot;
this.mainClass = builder.mainClass;
this.moduleRootDir = builder.moduleRootDir;
this.moduleXml = builder.moduleXml;
this.resources = builder.resources;
this.dependencies = builder.dependencies;
Expand All @@ -62,11 +64,17 @@ public void apply(OnlineCommandContext ctx) throws Exception {
cmd.append(" --name=").append(moduleName);
cmd.append(" --slot=").append(slot);

if (moduleXml != null)
if (moduleRootDir != null) {
cmd.append(" --module-root-dir=").append(moduleRootDir);
}

if (moduleXml != null) {
cmd.append(" --module-xml=").append(moduleXml);
}

if (mainClass != null)
if (mainClass != null) {
cmd.append(" --main-class=").append(mainClass);
}

Joiner resourcesJoiner = Joiner.on(File.pathSeparatorChar);
// resource-delimiter was added in WF 8, WFLY-1871
Expand Down Expand Up @@ -127,14 +135,15 @@ public String toString() {
}

public static final class Builder {
private char resourceDelimiter = File.pathSeparatorChar;
private final String moduleName;
private final String slot;
private char resourceDelimiter = File.pathSeparatorChar;
private String moduleXml;
private String moduleRootDir;
private String mainClass;
private List<String> resources;
private List<String> dependencies;
private List<String> properties;
private final List<String> resources;
private final List<String> dependencies;
private final List<String> properties;

/**
* @param moduleName the name of the module to be added (assumes the {@code main} slot)
Expand Down Expand Up @@ -206,6 +215,22 @@ public Builder dependency(String dependency) {
return this;
}

/**
* Use this argument if you have defined an external JBoss EAP module directory to use instead of the default
* EAP_HOME/modules/ directory.
*
* @see <a href="https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.3/html-single/configuration_guide/index#idm140645108782400">
* EAP Configuration guide
* </a>
*/
public Builder moduleRootDir(File moduleRootDir) {
if (moduleRootDir == null) {
throw new IllegalArgumentException("moduleRootDir file cannot be null");
}
this.moduleRootDir = moduleRootDir.getAbsolutePath();
return this;
}

/**
* The {@code module.xml} file which should be used for the added module. The file will be copied
* to the created module's directory. If this argument is not specified, {@code module.xml} file
Expand All @@ -224,10 +249,12 @@ public Builder moduleXml(File moduleXml) {
* i.e. when the {@link #moduleXml(File)} isn't specified.
*/
public Builder property(String name, String value) {
if (name == null)
if (name == null) {
throw new NullPointerException("property name cannot be null");
if (value == null)
}
if (value == null) {
throw new NullPointerException("property value cannot be null");
}
properties.add(name + "=" + value);
return this;
}
Expand All @@ -238,8 +265,9 @@ public Builder property(String name, String value) {
* isn't specified.
*/
public Builder mainClass(String mainClass) {
if (mainClass == null)
if (mainClass == null) {
throw new NullPointerException("mainClass cannot be null");
}
this.mainClass = mainClass;
return this;
}
Expand Down

0 comments on commit b24378f

Please sign in to comment.