iterate all interceptors to get the first returning valid goals

This commit is contained in:
imod committed 2011-11-23 16:16:53 +01:00
1 parent 74d2d4373c
commit 025cfd311a
1 file changed
+11 -6
@@ -754,17 +754,22 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
}
}
final List<MavenArgumentInterceptorAction> argInterceptors = this.getBuild().getActions(MavenArgumentInterceptorAction.class);
// find the correct maven goals and options, there might by an action overruling the defaults
// only one action is allowed to overwrite the hole "goals and options" string
final MavenArgumentInterceptorAction interceptorAction = this.getBuild().getAction(MavenArgumentInterceptorAction.class);
final String goals = interceptorAction != null && StringUtils.isNotBlank(interceptorAction.getGoalsAndOptions()) ? interceptorAction
.getGoalsAndOptions() : project.getGoals();
String goals = project.getGoals(); // default
for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) {
if(StringUtils.isNotBlank(mavenArgInterceptor.getGoalsAndOptions())){
goals = mavenArgInterceptor.getGoalsAndOptions();
// only one interceptor is allowed to overwrite the whole "goals and options" string
break;
}
}
margs.addTokenized(envVars.expand(goals));
// enable the interceptors to change the whole command argument list
// all available interceptors are allowed to modify the argument list
final List<MavenArgumentInterceptorAction> argInterceptors = this.getBuild().getActions(MavenArgumentInterceptorAction.class);
for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) {
final ArgumentListBuilder newMargs = mavenArgInterceptor.intercept(margs);
if (newMargs != null) {