mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
those class must be now dynamic for 3.0.x vers 3.1
This commit is contained in:
1 parent
b27b8e6961
commit
4e712aa7c3
3 files changed
+46
-14
No files matched your search
@@ -30,7 +30,6 @@ import hudson.model.BuildListener;
|
||||
import hudson.remoting.Which;
|
||||
import hudson.tasks.Maven.MavenInstallation;
|
||||
import org.jvnet.hudson.maven3.agent.Maven31Main;
|
||||
import org.jvnet.hudson.maven3.agent.Maven3Main;
|
||||
import org.jvnet.hudson.maven3.launcher.Maven31Interceptor;
|
||||
import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult;
|
||||
|
||||
@@ -58,7 +57,7 @@ public class Maven31ProcessFactory extends Maven3ProcessFactory
|
||||
@Override
|
||||
protected String getMavenAgentClassPath(MavenInstallation mvn,boolean isMaster,FilePath slaveRoot,BuildListener listener) throws IOException, InterruptedException {
|
||||
String classWorldsJar = getLauncher().getChannel().call(new Maven3ProcessFactory.GetClassWorldsJar(mvn.getHome(),listener));
|
||||
String path = (isMaster? Which.jarFile(Maven3Main.class).getAbsolutePath():slaveRoot.child("maven31-agent.jar").getRemote())+
|
||||
String path = (isMaster? Which.jarFile(Maven31Main.class).getAbsolutePath():slaveRoot.child("maven31-agent.jar").getRemote())+
|
||||
(getLauncher().isUnix()?":":";")+classWorldsJar;
|
||||
|
||||
return path;
|
||||
|
||||
@@ -37,8 +37,6 @@ import org.apache.maven.execution.ExecutionListener;
|
||||
import org.apache.maven.plugin.MojoExecution;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.jvnet.hudson.maven3.agent.Maven3Main;
|
||||
import org.jvnet.hudson.maven3.launcher.Maven3Launcher;
|
||||
import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -46,6 +44,7 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
@@ -57,7 +56,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static hudson.Util.*;
|
||||
import static hudson.Util.fixNull;
|
||||
|
||||
/**
|
||||
* @author Olivier Lamy
|
||||
@@ -71,15 +70,23 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
|
||||
*/
|
||||
private final boolean profile = MavenProcessFactory.profile;
|
||||
|
||||
HudsonMavenExecutionResult mavenExecutionResult;
|
||||
HudsonMavenExecutionResult mavenExecutionResult;
|
||||
|
||||
Class<?> maven3MainClass;
|
||||
|
||||
Class<?> maven3LauncherClass;
|
||||
|
||||
protected Maven3Builder(BuildListener listener,Map<ModuleName,ProxyImpl2> proxies, Collection<MavenModule> modules, List<String> goals, Map<String, String> systemProps, MavenBuildInformation mavenBuildInformation) {
|
||||
protected Maven3Builder(BuildListener listener,Map<ModuleName,ProxyImpl2> proxies, Collection<MavenModule> modules,
|
||||
List<String> goals, Map<String, String> systemProps, MavenBuildInformation mavenBuildInformation,
|
||||
Class<?> maven3MainClass, Class<?> maven3LauncherClass) {
|
||||
super( listener, modules, goals, systemProps );
|
||||
this.sourceProxies.putAll(proxies);
|
||||
this.proxies = new HashMap<ModuleName, FilterImpl>();
|
||||
for (Entry<ModuleName,ProxyImpl2> e : this.sourceProxies.entrySet()) {
|
||||
this.proxies.put(e.getKey(), new FilterImpl(e.getValue(), mavenBuildInformation));
|
||||
}
|
||||
this.maven3MainClass = maven3MainClass;
|
||||
this.maven3LauncherClass = maven3LauncherClass;
|
||||
}
|
||||
|
||||
public Result call() throws IOException {
|
||||
@@ -88,7 +95,12 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
|
||||
initializeAsynchronousExecutions();
|
||||
|
||||
MavenExecutionListener mavenExecutionListener = new MavenExecutionListener( this );
|
||||
Maven3Launcher.setMavenExecutionListener( mavenExecutionListener );
|
||||
|
||||
Method setMavenExecutionListenerMethod = maven3LauncherClass.getMethod( "setMavenExecutionListener", ExecutionListener.class );
|
||||
|
||||
setMavenExecutionListenerMethod.invoke( null, mavenExecutionListener );
|
||||
|
||||
//Maven3Launcher.setMavenExecutionListener( mavenExecutionListener );
|
||||
|
||||
markAsSuccess = false;
|
||||
|
||||
@@ -96,8 +108,13 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
|
||||
|
||||
listener.getLogger().println(formatArgs(goals));
|
||||
|
||||
Method launchMethod = maven3MainClass.getMethod( "launch", String[].class );
|
||||
|
||||
int r = Maven3Main.launch( goals.toArray(new String[goals.size()]));
|
||||
Integer res = (Integer) launchMethod.invoke(null, new Object[] {goals.toArray(new String[goals.size()])} );
|
||||
|
||||
//int r = Maven3Main.launch( goals.toArray(new String[goals.size()]));
|
||||
|
||||
int r = res.intValue();
|
||||
|
||||
// now check the completion status of async ops
|
||||
long startTime = System.nanoTime();
|
||||
@@ -118,7 +135,11 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
|
||||
logger.println("Resource loading "+format(n,ch.resourceLoadingTime.get())+"ms, "+ch.resourceLoadingCount+" times");
|
||||
}
|
||||
|
||||
mavenExecutionResult = Maven3Launcher.getMavenExecutionResult();
|
||||
Method mavenExecutionResultGetMethod = maven3LauncherClass.getMethod( "getMavenExecutionResult", null );
|
||||
|
||||
mavenExecutionResult = (HudsonMavenExecutionResult) mavenExecutionResultGetMethod.invoke( null, null );
|
||||
|
||||
//mavenExecutionResult = Maven3Launcher.getMavenExecutionResult();
|
||||
|
||||
PrintStream logger = listener.getLogger();
|
||||
|
||||
@@ -156,8 +177,8 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
|
||||
throw new IOException2(e);
|
||||
} catch (InvocationTargetException e) {
|
||||
throw new IOException2(e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new IOException2(e);
|
||||
//} catch (ClassNotFoundException e) {
|
||||
// throw new IOException2(e);
|
||||
} catch (Exception e) {
|
||||
throw new IOException2(e);
|
||||
} finally {
|
||||
|
||||
@@ -97,6 +97,10 @@ import org.apache.maven.model.building.ModelBuildingRequest;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.ProjectBuildingException;
|
||||
import org.codehaus.plexus.util.PathTool;
|
||||
import org.jvnet.hudson.maven3.agent.Maven31Main;
|
||||
import org.jvnet.hudson.maven3.agent.Maven3Main;
|
||||
import org.jvnet.hudson.maven3.launcher.Maven31Launcher;
|
||||
import org.jvnet.hudson.maven3.launcher.Maven3Launcher;
|
||||
import org.kohsuke.stapler.StaplerRequest;
|
||||
import org.kohsuke.stapler.StaplerResponse;
|
||||
import org.kohsuke.stapler.export.Exported;
|
||||
@@ -685,6 +689,10 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
|
||||
final ProcessCache.Factory factory;
|
||||
|
||||
Class<?> maven3MainClass = null;
|
||||
|
||||
Class<?> maven3LauncherClass = null;
|
||||
|
||||
switch ( mavenVersionType ){
|
||||
case MAVEN_2:
|
||||
LOGGER.fine( "using maven 2 " + mavenVersion );
|
||||
@@ -695,12 +703,15 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
LOGGER.fine( "using maven 3 " + mavenVersion );
|
||||
factory = new Maven3ProcessFactory( project, MavenModuleSetBuild.this, launcher, envVars, getMavenOpts(listener, envVars),
|
||||
pom.getParent() );
|
||||
maven3MainClass = Maven3Main.class;
|
||||
maven3LauncherClass = Maven3Launcher.class;
|
||||
break;
|
||||
default:
|
||||
LOGGER.fine( "using maven 3 " + mavenVersion );
|
||||
factory = new Maven31ProcessFactory( project, MavenModuleSetBuild.this, launcher, envVars, getMavenOpts(listener, envVars),
|
||||
pom.getParent() );
|
||||
|
||||
maven3MainClass = Maven31Main.class;
|
||||
maven3LauncherClass = Maven31Launcher.class;
|
||||
}
|
||||
|
||||
process = MavenBuild.mavenProcessCache.get( launcher.getChannel(), slistener, factory);
|
||||
@@ -768,7 +779,8 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
final AbstractMavenBuilder builder;
|
||||
if (maven3orLater) {
|
||||
builder =
|
||||
new Maven3Builder(slistener, proxies, project.sortedActiveModules, margs.toList(), envVars, mavenBuildInformation );
|
||||
new Maven3Builder(slistener, proxies, project.sortedActiveModules, margs.toList(), envVars,
|
||||
mavenBuildInformation, maven3MainClass, maven3LauncherClass);
|
||||
} else {
|
||||
builder =
|
||||
new Maven2Builder(slistener, proxies, project.sortedActiveModules, margs.toList(), envVars, mavenBuildInformation);
|
||||
|
||||
Reference in new issue
Block a user