From 025cfd311a8835f0fc161e369393ca5df4182cd4 Mon Sep 17 00:00:00 2001 From: imod Date: Wed, 23 Nov 2011 12:52:22 +0100 Subject: [PATCH] iterate all interceptors to get the first returning valid goals --- .../java/hudson/maven/MavenModuleSetBuild.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 1383506f3b..b0ab161665 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -754,17 +754,22 @@ public class MavenModuleSetBuild extends AbstractMavenBuild 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 argInterceptors = this.getBuild().getActions(MavenArgumentInterceptorAction.class); for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) { final ArgumentListBuilder newMargs = mavenArgInterceptor.intercept(margs); if (newMargs != null) {