提交 9519de18 编写于 作者: I imod

additionaly pass reference to current build to intercepting methods

上级 fda6daa0
......@@ -45,16 +45,19 @@ public interface MavenArgumentInterceptorAction extends Action {
* This method will be called on one and only one action during a build. If
* there are two actions present in the build, the second will be ignored.
*
* @param build
* reference to the current build, might be used for some
* calculations for the correct arguments
* @return the maven goals and options to start maven with. Result is
* ignored if <code>null</code> or empty. Variables will be expanded
* by the caller.
*/
public String getGoalsAndOptions();
public String getGoalsAndOptions(MavenModuleSetBuild build);
/**
* Change/add arguments to any needs, but special care has to be taken, as
* the list contains every argument needed for the default execution (e.g.
* -f /path/to/pom.xml or -B). <br />
* <code>-f /path/to/pom.xml</code> or <code>-B</code>). <br />
* An easy example would be to add "<code>-DskipTests</code>" to skip the
* test execution on request.
*
......@@ -66,8 +69,11 @@ public interface MavenArgumentInterceptorAction extends Action {
* @param mavenargs
* the calculated default maven arguments (never
* <code>null</code>).
* @param build
* reference to the current build, might be used for some
* calculations for the correct arguments
* @return the new arguments to be used.
*/
public ArgumentListBuilder intercept(ArgumentListBuilder mavenargs);
public ArgumentListBuilder intercept(ArgumentListBuilder mavenargs, MavenModuleSetBuild build);
}
......@@ -760,7 +760,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
// find the correct maven goals and options, there might by an action overruling the defaults
String goals = project.getGoals(); // default
for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) {
final String goalsAndOptions = mavenArgInterceptor.getGoalsAndOptions();
final String goalsAndOptions = mavenArgInterceptor.getGoalsAndOptions(this.getBuild());
if(StringUtils.isNotBlank(goalsAndOptions)){
goals = goalsAndOptions;
// only one interceptor is allowed to overwrite the whole "goals and options" string
......@@ -772,7 +772,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
// enable the interceptors to change the whole command argument list
// all available interceptors are allowed to modify the argument list
for (MavenArgumentInterceptorAction mavenArgInterceptor : argInterceptors) {
final ArgumentListBuilder newMargs = mavenArgInterceptor.intercept(margs);
final ArgumentListBuilder newMargs = mavenArgInterceptor.intercept(margs, this.getBuild());
if (newMargs != null) {
margs = newMargs;
}
......
......@@ -105,11 +105,11 @@ public class MavenArgumentInterceptorTest extends HudsonTestCase {
return null;
}
public String getGoalsAndOptions() {
public String getGoalsAndOptions(MavenModuleSetBuild build) {
return goalsAndOptions;
}
public ArgumentListBuilder intercept(ArgumentListBuilder mavenargs) {
public ArgumentListBuilder intercept(ArgumentListBuilder mavenargs, MavenModuleSetBuild build) {
if (args != null) {
for (String arg : this.args) {
mavenargs.add(arg);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册