@@ -50,13 +50,8 @@ public void execute() throws MojoExecutionException {
50
50
final String artifactId = project .getArtifactId ();
51
51
final String groupId = project .getGroupId ();
52
52
53
- final StringBuilder processedMvnTestOpts = new StringBuilder (" " );
54
- processedMvnTestOpts .append (mvnTestOpts );
55
- processedMvnTestOpts .append (" -pl " ).append (groupId );
56
- processedMvnTestOpts .append (":" ).append (artifactId );
57
-
58
53
int exitCode ;
59
- final String command = "mvn test " + processedMvnTestOpts ;
54
+ final String command = "mvn test " + buildProcessedMvnTestOpts ( artifactId , groupId ) ;
60
55
try {
61
56
exitCode = runShellCommand (command , "supertest run#1" );
62
57
} catch (IOException | InterruptedException e ) {
@@ -67,7 +62,10 @@ public void execute() throws MojoExecutionException {
67
62
return ;
68
63
}
69
64
70
- for (int retryRunNumber = 1 ; retryRunNumber <= retryRunCount .intValue (); retryRunNumber ++) {
65
+ // Strip -Dtest=... from the Maven opts if specified, since these were valid for the very first run only.
66
+ mvnTestOpts = mvnTestOpts .replaceAll ("-Dtest=(.*?)(\\ s|$)" , "" );
67
+
68
+ for (int retryRunNumber = 1 ; retryRunNumber <= retryRunCount ; retryRunNumber ++) {
71
69
final File [] xmlFileList = getXmlFileList (baseDir );
72
70
final Map <String , List <String >> classnameToTestcaseList = new HashMap <>();
73
71
for (File file : xmlFileList ) {
@@ -84,7 +82,7 @@ public void execute() throws MojoExecutionException {
84
82
85
83
final String runCommand = createRerunCommand (classnameToTestcaseList );
86
84
final StringBuilder rerunCommand = new StringBuilder (runCommand );
87
- rerunCommand .append (processedMvnTestOpts );
85
+ rerunCommand .append (buildProcessedMvnTestOpts ( artifactId , groupId ) );
88
86
if (rerunProfile != null ) {
89
87
String trimmedRerunProfile = rerunProfile .replaceAll ("\" " , "" );
90
88
rerunCommand .append (" -P " ).append (trimmedRerunProfile );
@@ -108,12 +106,21 @@ public void execute() throws MojoExecutionException {
108
106
}
109
107
}
110
108
109
+ private StringBuilder buildProcessedMvnTestOpts (String artifactId , String groupId ) {
110
+ final StringBuilder processedMvnTestOpts = new StringBuilder (" " );
111
+ processedMvnTestOpts .append (mvnTestOpts );
112
+ processedMvnTestOpts .append (" -pl " ).append (groupId );
113
+ processedMvnTestOpts .append (":" ).append (artifactId );
114
+ return processedMvnTestOpts ;
115
+ }
116
+
111
117
/**
112
118
* @param command shell command to be executed
113
119
* @return process exit value, returns 1 if failure
114
120
*/
115
121
public int runShellCommand (final String command , final String commandDescriptor )
116
122
throws IOException , InterruptedException {
123
+ getLog ().info ("Running " + command );
117
124
Process proc = Runtime .getRuntime ().exec (command );
118
125
InputStream inputStream = proc .getInputStream ();
119
126
InputStreamReader inputStreamReader = new InputStreamReader (inputStream );
0 commit comments