@@ -54,11 +54,13 @@ a copy of this software and associated documentation files (the
5454import edu .illinois .nondex .common .Logger ;
5555import edu .illinois .nondex .common .Utils ;
5656
57+ import org .apache .maven .model .PluginExecution ;
5758import org .apache .maven .plugin .MojoExecutionException ;
5859import org .apache .maven .plugin .MojoFailureException ;
5960import org .apache .maven .plugins .annotations .LifecyclePhase ;
6061import org .apache .maven .plugins .annotations .Mojo ;
6162import org .apache .maven .plugins .annotations .ResolutionScope ;
63+ import org .codehaus .plexus .util .xml .Xpp3Dom ;
6264
6365@ Mojo (name = "nondex" , defaultPhase = LifecyclePhase .TEST , requiresDependencyResolution = ResolutionScope .TEST )
6466public class NonDexMojo extends AbstractNonDexMojo {
@@ -80,28 +82,22 @@ public void execute() throws MojoExecutionException, MojoFailureException {
8082
8183 // If we add clean exceptions to allExceptions then the build fails if anything fails without nondex.
8284 // Everything in nondex-test is expected to fail without nondex so we throw away the result here.
83- for (int j = 0 ; j < this .numRunsWithoutShuffling ; j ++) {
84- CleanSurefireExecution cleanExec = new CleanSurefireExecution (
85- this .surefire , this .originalArgLine , this .mavenProject ,
86- this .mavenSession , this .pluginManager ,
87- Paths .get (this .baseDir .getAbsolutePath (), ConfigurationDefaults .DEFAULT_NONDEX_DIR ).toString ());
88- this .executeSurefireExecution (allExceptions , cleanExec );
89- this .executionsWithoutShuffling .add (cleanExec );
90- }
9185
92- for (int i = 0 ; i < this .numRuns ; i ++) {
93- NonDexSurefireExecution execution =
94- new NonDexSurefireExecution (this .mode , this .computeIthSeed (i ),
95- Pattern .compile (this .filter ), this .start , this .end ,
96- Paths .get (this .baseDir .getAbsolutePath (), ConfigurationDefaults .DEFAULT_NONDEX_DIR ).toString (),
97- Paths .get (this .baseDir .getAbsolutePath (), ConfigurationDefaults .DEFAULT_NONDEX_JAR_DIR )
98- .toString (),
99- this .surefire , this .originalArgLine , this .mavenProject ,
100- this .mavenSession , this .pluginManager );
101- setFilePath (execution .getConfiguration ().getRunFilePath ());
102- this .executions .add (execution );
103- allExceptions = this .executeSurefireExecution (allExceptions , execution );
104- this .writeCurrentRunInfo (execution );
86+ if (this .surefire .getExecutions () != null && !this .surefire .getExecutions ().isEmpty ()) {
87+ // We need to do this because Xpp3Dom doesn't accept null yet setConfiguration accepts null.
88+ Xpp3Dom origNode = null ;
89+ if (this .surefire .getConfiguration () != null ) {
90+ origNode = (Xpp3Dom ) this .surefire .getConfiguration ();
91+ }
92+ for (PluginExecution exec : this .surefire .getExecutions ()) {
93+ if (exec .getConfiguration () != null ) {
94+ this .surefire .setConfiguration ((Xpp3Dom ) exec .getConfiguration ());
95+ }
96+ allExceptions = this .runExecutions (allExceptions );
97+ this .surefire .setConfiguration (origNode );
98+ }
99+ } else {
100+ allExceptions = this .runExecutions (allExceptions );
105101 }
106102
107103 for (CleanSurefireExecution cleanExec : this .executionsWithoutShuffling ) {
@@ -123,7 +119,33 @@ public void execute() throws MojoExecutionException, MojoFailureException {
123119 if (allExceptions != null ) {
124120 throw allExceptions ;
125121 }
122+ }
126123
124+ private MojoExecutionException runExecutions (MojoExecutionException allExceptions ) {
125+ for (int j = 0 ; j < this .numRunsWithoutShuffling ; j ++) {
126+ CleanSurefireExecution cleanExec = new CleanSurefireExecution (
127+ this .surefire , this .originalArgLine , this .mavenProject ,
128+ this .mavenSession , this .pluginManager ,
129+ Paths .get (this .baseDir .getAbsolutePath (), ConfigurationDefaults .DEFAULT_NONDEX_DIR ).toString ());
130+ this .executeSurefireExecution (allExceptions , cleanExec );
131+ this .executionsWithoutShuffling .add (cleanExec );
132+ }
133+ for (int i = 0 ; i < this .numRuns ; i ++) {
134+ NonDexSurefireExecution execution =
135+ new NonDexSurefireExecution (this .mode , this .computeIthSeed (i ),
136+ Pattern .compile (this .filter ), this .start , this .end ,
137+ Paths .get (this .baseDir .getAbsolutePath (), ConfigurationDefaults .DEFAULT_NONDEX_DIR )
138+ .toString (),
139+ Paths .get (this .baseDir .getAbsolutePath (), ConfigurationDefaults .DEFAULT_NONDEX_JAR_DIR )
140+ .toString (),
141+ this .surefire , this .originalArgLine , this .mavenProject ,
142+ this .mavenSession , this .pluginManager );
143+ setFilePath (execution .getConfiguration ().getRunFilePath ());
144+ this .executions .add (execution );
145+ allExceptions = this .executeSurefireExecution (allExceptions , execution );
146+ this .writeCurrentRunInfo (execution );
147+ }
148+ return allExceptions ;
127149 }
128150
129151 private void postProcessExecutions (CleanSurefireExecution cleanExec ) {
0 commit comments