Skip to content

Commit 4b30861

Browse files
authored
Merge pull request #17 from gsmet/issue-16
Provide the ability to define JVM options with the Maven plugin
2 parents fa9f0fb + 6793424 commit 4b30861

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

patch-gen-maven-plugin/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
<version>3.2</version>
3434
<scope>provided</scope>
3535
</dependency>
36+
<dependency>
37+
<groupId>org.apache.maven.shared</groupId>
38+
<artifactId>maven-shared-utils</artifactId>
39+
<version>3.1.0</version>
40+
</dependency>
3641
</dependencies>
3742

3843
<build>

patch-gen-maven-plugin/src/main/java/org/jboss/as/patch/generator/maven/plugin/PatchGenMojo.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
import org.apache.maven.plugins.annotations.LifecyclePhase;
3333
import org.apache.maven.plugins.annotations.Mojo;
3434
import org.apache.maven.plugins.annotations.Parameter;
35+
import org.apache.maven.shared.utils.cli.CommandLineException;
36+
import org.apache.maven.shared.utils.cli.CommandLineUtils;
3537
import org.jboss.as.patching.generator.PatchGenerator;
3638

3739
/**
@@ -102,6 +104,9 @@ public class PatchGenMojo extends AbstractMojo {
102104
@Parameter( property = "combineWith" )
103105
private File combineWith;
104106

107+
@Parameter( property = "argLine" )
108+
private String argLine;
109+
105110
@Parameter( property = "project.build.directory" )
106111
private File buildDirectory;
107112

@@ -113,6 +118,11 @@ public void execute() throws MojoExecutionException {
113118
List<String> args = new ArrayList<>();
114119

115120
args.add( "java" );
121+
122+
for ( String additionalArg : getAdditionalArgs() ) {
123+
args.add( additionalArg );
124+
}
125+
116126
args.add( "-cp" );
117127
args.add( getClasspath() );
118128
args.add( PatchGenerator.class.getName() );
@@ -181,4 +191,17 @@ private String getClasspath() {
181191

182192
return sb.toString();
183193
}
194+
195+
private String[] getAdditionalArgs() throws MojoExecutionException {
196+
if ( argLine == null || argLine.trim().length() == 0 ) {
197+
return new String[0];
198+
}
199+
200+
try {
201+
return CommandLineUtils.translateCommandline( argLine.replace( "\n", " " ).replaceAll( "\r", " " ) );
202+
}
203+
catch (CommandLineException e) {
204+
throw new MojoExecutionException( "Unable to parse argLine: " + argLine, e );
205+
}
206+
}
184207
}

0 commit comments

Comments
 (0)