提交 0fcf658c 编写于 作者: O Olivier Lamy

[HUDSON-4988] Maven 3 support in maven-plugin

fixing missing wagon providers
上级 478c0c43
......@@ -278,6 +278,12 @@ public class Main {
URLClassLoader orig = (URLClassLoader) Thread.currentThread().getContextClassLoader();
System.out.println("orig " + orig.toString());
URL cl = orig.getResource( "org/apache/maven/plugin/PluginManager.class" );
if (cl != null)
{
System.out.println("cl " + cl.toString());
}
// org.apache.maven.plugin.PluginManager
try {
launcher.setAppMain( "org.apache.maven.cli.MavenCli", "plexus.core.maven" );
......
......@@ -115,6 +115,19 @@ THE SOFTWARE.
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId>
......
......@@ -80,7 +80,7 @@ public final class ExecutedMojo implements Serializable {
*/
public final String digest;
ExecutedMojo(MojoInfo mojo, long duration) throws IOException, InterruptedException {
public ExecutedMojo(MojoInfo mojo, long duration) throws IOException, InterruptedException {
this.groupId = mojo.pluginName.groupId;
this.artifactId = mojo.pluginName.artifactId;
this.version = mojo.pluginName.version;
......
......@@ -54,15 +54,12 @@ import org.apache.maven.execution.ExecutionListener;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.Mojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.PluginConfigurationException;
import org.apache.maven.plugin.PluginContainerException;
import org.apache.maven.plugin.PluginParameterExpressionEvaluator;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluator;
import org.codehaus.plexus.configuration.xml.XmlPlexusConfiguration;
import org.jvnet.hudson.maven3.agent.Maven3Main;
import org.jvnet.hudson.maven3.launcher.Maven3Launcher;
import org.jvnet.hudson.maven3.listeners.HudsonMavenBuildHelper;
import org.jvnet.hudson.maven3.listeners.HudsonMavenExecutionResult;
/**
......@@ -279,10 +276,13 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
return null;
}
// FIME really used somewhere ???
// FIXME MojoInfo need the real mojo ??
// so tricky to do need to use MavenPluginManager on the current Maven Build
// so tricky to do. need to use MavenPluginManager on the current Maven Build
private Mojo getMojo(MojoExecution mojoExecution, MavenSession mavenSession)
{
return null;
/*
try
{
return HudsonMavenBuildHelper.getMavenPluginManager().getConfiguredMojo( Mojo.class, mavenSession,
......@@ -295,7 +295,7 @@ public class Maven3Builder extends AbstractMavenBuilder implements DelegatingCal
catch ( PluginConfigurationException e )
{
throw new RuntimeException( e.getMessage(), e );
}
}*/
}
private ExpressionEvaluator getExpressionEvaluator(MavenSession session, MojoExecution mojoExecution)
......
......@@ -410,7 +410,7 @@ public class MavenBuild extends AbstractMavenBuild<MavenModule,MavenBuild> {
}
}
class ProxyImpl2 extends ProxyImpl implements MavenBuildProxy2 {
public class ProxyImpl2 extends ProxyImpl implements MavenBuildProxy2 {
private final SplittableBuildListener listener;
long startTime;
private final OutputStream log;
......
......@@ -597,6 +597,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
}
} else {
Builder builder = new Builder(slistener, proxies, project.sortedActiveModules, margs.toList(), envVars);
MavenProbeAction mpa=null;
try {
......@@ -819,6 +820,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
}
}
@Override
void preBuild(MavenSession session, ReactorManager rm, EventDispatcher dispatcher) throws BuildFailureException, LifecycleExecutionException, IOException, InterruptedException {
// set all modules which are not actually being build (in incremental builds) to NOT_BUILD
......@@ -1044,6 +1046,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
MavenEmbedder embedder = MavenUtil.
createEmbedder(listener, mavenHome.getHomeDir(), profiles,
properties, privateRepository, settingsLoc);
MavenProject mp = embedder.readProject(pom);
Map<MavenProject,String> relPath = new HashMap<MavenProject,String>();
MavenUtil.resolveModules(embedder,mp,getRootPath(rootPOMRelPrefix),relPath,listener,nonRecursive);
......
......@@ -210,38 +210,45 @@ public class MavenUtil {
* errors will be reported to the listener and the exception thrown.
* @throws MavenEmbedderException
*/
public static void resolveModules(MavenEmbedder embedder, MavenProject project,
String rel, Map<MavenProject,String> relativePathInfo,
BuildListener listener, boolean nonRecursive) throws ProjectBuildingException,
AbortException, MavenEmbedderException {
public static void resolveModules( MavenEmbedder embedder, MavenProject project, String rel,
Map<MavenProject, String> relativePathInfo, BuildListener listener,
boolean nonRecursive )
throws ProjectBuildingException, AbortException, MavenEmbedderException
{
File basedir = project.getFile().getParentFile();
relativePathInfo.put(project,rel);
if (!nonRecursive) {
List<MavenProject> modules = new ArrayList<MavenProject>();
for (String modulePath : (List<String>) project.getModules()) {
if (Util.fixEmptyAndTrim(modulePath)!=null) {
File moduleFile = new File(basedir, modulePath);
if (moduleFile.exists() && moduleFile.isDirectory()) {
moduleFile = new File(basedir, modulePath + "/pom.xml");
}
if(!moduleFile.exists())
throw new AbortException(moduleFile+" is referenced from "+project.getFile()+" but it doesn't exist");
String relativePath = rel;
if(relativePath.length()>0) relativePath+='/';
relativePath+=modulePath;
MavenProject child = embedder.readProject(moduleFile);
resolveModules(embedder,child,relativePath,relativePathInfo,listener,nonRecursive);
modules.add(child);
}
}
project.setCollectedProjects(modules);
}
relativePathInfo.put( project, rel );
if ( !nonRecursive )
{
List<MavenProject> modules = new ArrayList<MavenProject>();
for ( String modulePath : (List<String>) project.getModules() )
{
if ( Util.fixEmptyAndTrim( modulePath ) != null )
{
File moduleFile = new File( basedir, modulePath );
if ( moduleFile.exists() && moduleFile.isDirectory() )
{
moduleFile = new File( basedir, modulePath + "/pom.xml" );
}
if ( !moduleFile.exists() )
throw new AbortException( moduleFile + " is referenced from " + project.getFile()
+ " but it doesn't exist" );
String relativePath = rel;
if ( relativePath.length() > 0 )
relativePath += '/';
relativePath += modulePath;
MavenProject child = embedder.readProject( moduleFile );
resolveModules( embedder, child, relativePath, relativePathInfo, listener, nonRecursive );
modules.add( child );
}
}
project.setCollectedProjects( modules );
}
}
/**
......
......@@ -22,10 +22,8 @@ package org.jvnet.hudson.maven3.listeners;
import javax.inject.Inject;
import org.apache.maven.plugin.MavenPluginManager;
import org.codehaus.plexus.PlexusContainer;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
......@@ -39,7 +37,7 @@ public class HudsonMavenBuildHelper implements Initializable
// must be available in a static way weird
// and not really good design !
private static MavenPluginManager mavenPluginManager;
//private static MavenPluginManager mavenPluginManager;
@Inject
private PlexusContainer plexusContainer;
......@@ -47,6 +45,7 @@ public class HudsonMavenBuildHelper implements Initializable
public void initialize()
throws InitializationException
{
/*
try
{
mavenPluginManager = plexusContainer.lookup( MavenPluginManager.class );
......@@ -55,12 +54,12 @@ public class HudsonMavenBuildHelper implements Initializable
{
throw new InitializationException(e.getMessage(), e);
}
*/
}
public static MavenPluginManager getMavenPluginManager()
/*public static MavenPluginManager getMavenPluginManager()
{
return mavenPluginManager;
}
}*/
}
......@@ -299,6 +299,22 @@ THE SOFTWARE.
<artifactId>aether-connector-wagon</artifactId>
<version>${aetherVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-lightweight</artifactId>
<version>${wagonVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-file</artifactId>
<version>${wagonVersion}</version>
</dependency>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-provider-api</artifactId>
<version>${wagonVersion}</version>
</dependency>
<dependency>
<groupId>org.sonatype.sisu</groupId>
<artifactId>sisu-inject-plexus</artifactId>
......@@ -326,6 +342,7 @@ THE SOFTWARE.
<mavenVersion>3.0.1</mavenVersion>
<maven.version>${mavenVersion}</maven.version>
<aetherVersion>1.8</aetherVersion>
<wagonVersion>1.0-beta-6</wagonVersion>
<!-- *.html files are in UTF-8, and *.properties are in iso-8859-1, so this configuration is acturally incorrect,
but this suppresses a warning from Maven, and as long as we don't do filtering we should be OK. -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册