diff --git a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java index 901f192f252d6219f03565f14833c218152e3ca9..c1db80fc45dadac560f8c3681f856641781e879d 100644 --- a/maven-plugin/src/main/java/hudson/maven/MavenBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenBuild.java @@ -1,7 +1,7 @@ /* * The MIT License * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi + * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Olivier Lamy * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -45,6 +45,7 @@ import hudson.tasks.BuildWrapper; import hudson.tasks.Maven.MavenInstallation; import hudson.util.ArgumentListBuilder; import hudson.util.IOUtils; +import hudson.util.ReflectionUtils; import java.io.File; import java.io.FileNotFoundException; @@ -52,6 +53,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.Serializable; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -66,8 +68,6 @@ import org.apache.maven.execution.ReactorManager; import org.apache.maven.lifecycle.LifecycleExecutionException; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.project.MavenProject; -import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException; -import org.jenkinsci.plugins.tokenmacro.TokenMacro; import org.kohsuke.stapler.Ancestor; import org.kohsuke.stapler.Stapler; import org.kohsuke.stapler.StaplerRequest; @@ -682,9 +682,13 @@ public class MavenBuild extends AbstractMavenBuild { String opts = mms.getMavenOpts(); if (opts == null ) return null; try { - opts = TokenMacro.expand(this, listener, opts); - } catch (MacroEvaluationException e) { - listener.error( "Ignore MacroEvaluationException " + e.getMessage() ); + Class clazz = Class.forName( "org.jenkinsci.plugins.tokenmacro.MacroEvaluationException" ); + Method expandMethod = + ReflectionUtils.findMethod(clazz, "expand", new Class[]{ this.getClass(), listener.getClass(), String.class} ); + opts = (String) expandMethod.invoke( null, this, listener, opts ); + //opts = TokenMacro.expand(this, listener, opts); + //} catch (MacroEvaluationException e) { + // listener.error( "Ignore MacroEvaluationException " + e.getMessage() ); } catch(Exception tokenException) { listener.error("Ignore Problem expanding maven opts macros " + tokenException.getMessage()); diff --git a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java index 066b5496245158de81cdb2487189bcc326aa18dd..49c811776cfde924124614d60b43d0085a027fe3 100755 --- a/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java +++ b/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java @@ -60,6 +60,7 @@ import hudson.tasks.Maven.MavenInstallation; import hudson.util.ArgumentListBuilder; import hudson.util.IOUtils; import hudson.util.MaskingClassLoader; +import hudson.util.ReflectionUtils; import hudson.util.StreamTaskListener; import java.io.File; @@ -67,6 +68,7 @@ import java.io.IOException; import java.io.InterruptedIOException; import java.io.PrintStream; import java.io.Serializable; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -92,11 +94,7 @@ import org.apache.maven.model.building.ModelBuildingRequest; import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingException; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.configuration.DefaultPlexusConfiguration; import org.codehaus.plexus.util.PathTool; -import org.jenkinsci.plugins.tokenmacro.MacroEvaluationException; -import org.jenkinsci.plugins.tokenmacro.TokenMacro; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; import org.sonatype.aether.transfer.TransferCancelledException; @@ -528,9 +526,13 @@ public class MavenModuleSetBuild extends AbstractMavenBuild clazz = Class.forName( "org.jenkinsci.plugins.tokenmacro.MacroEvaluationException" ); + Method expandMethod = + ReflectionUtils.findMethod(clazz, "expand", new Class[]{ this.getClass(), listener.getClass(), String.class} ); + opts = (String) expandMethod.invoke( null, this, listener, opts ); + //opts = TokenMacro.expand(this, listener, opts); + //} catch (MacroEvaluationException e) { + // listener.error( "Ignore MacroEvaluationException " + e.getMessage() ); } catch(Exception tokenException) { listener.error("Ignore Problem expanding maven opts macros " + tokenException.getMessage());