Skip to content

Commit bf7be05

Browse files
authored
Allow a custom maven command. (#27)
This allows the plugin to play nicely with Maven Wrapper (./mvnw).
1 parent ac97849 commit bf7be05

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/main/java/com/clevertap/maven/plugins/supertest/SuperTestMavenPlugin.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
@Mojo(name = "supertest")
3535
public class SuperTestMavenPlugin extends AbstractMojo {
36+
3637
// this is the max time to wait in seconds for process termination after the stdout read is
3738
// finished or terminated
3839
private static final int STDOUT_POST_READ_WAIT_TIMEOUT = 10;
@@ -46,6 +47,10 @@ public class SuperTestMavenPlugin extends AbstractMojo {
4647
@Parameter(defaultValue = "${project}", readonly = true)
4748
MavenProject project;
4849

50+
51+
@Parameter(property = "mavenCommand", defaultValue = "mvn", readonly = true)
52+
String mavenCommand = "mvn";
53+
4954
@Parameter(property = "mvnTestOpts", readonly = true)
5055
String mvnTestOpts;
5156

@@ -97,7 +102,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
97102
getLog().debug("Test classes found: " + String.join(",", allTestClasses));
98103

99104
int exitCode;
100-
final String command = "mvn test " + buildProcessedMvnTestOpts(artifactId, groupId);
105+
final String command =
106+
mavenCommand + " test " + buildProcessedMvnTestOpts(artifactId, groupId);
101107
try {
102108
exitCode = runShellCommand(command, "supertest run#1");
103109
} catch (IOException | InterruptedException e) {
@@ -329,7 +335,7 @@ public File[] getXmlFileList(File baseDir) {
329335
*/
330336
public String createRerunCommand(
331337
Set<String> allTestClasses, Map<String, List<String>> classnameToTestcaseList) {
332-
final StringBuilder retryRun = new StringBuilder("mvn test");
338+
final StringBuilder retryRun = new StringBuilder(mavenCommand + " test");
333339
Set<String> incompleteTests = new HashSet<>(allTestClasses);
334340

335341
retryRun.append(" -Dtest=");
@@ -364,8 +370,8 @@ private void appendFailedTestCases(
364370
String className, List<String> failedTestCaseList, StringBuilder retryRun) {
365371
retryRun.append(className);
366372

367-
if (failedTestCaseList.contains("")) {
368-
retryRun.append(",");
373+
if (failedTestCaseList.contains("")) {
374+
retryRun.append(",");
369375
return;
370376
}
371377

0 commit comments

Comments
 (0)