updating to new apis

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@322531 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2005-10-17 00:43:01 +00:00
parent bf402d7709
commit 5008852983
4 changed files with 93 additions and 84 deletions

View File

@ -2,13 +2,18 @@
<parent> <parent>
<artifactId>maven</artifactId> <artifactId>maven</artifactId>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<version>2.0-beta-4-SNAPSHOT</version> <version>2.0.1-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId> <artifactId>maven-embedder</artifactId>
<name>Maven Embedder</name> <name>Maven Embedder</name>
<version>2.0-beta-4-SNAPSHOT</version> <version>2.0</version>
<properties>
<mavenVersion>2.0.1-SNAPSHOT</mavenVersion>
</properties>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -32,7 +37,7 @@
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-settings</artifactId> <artifactId>maven-settings</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
@ -49,22 +54,22 @@
<dependency> <dependency>
<groupId>org.apache.maven.reporting</groupId> <groupId>org.apache.maven.reporting</groupId>
<artifactId>maven-reporting-api</artifactId> <artifactId>maven-reporting-api</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-profile</artifactId> <artifactId>maven-profile</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId> <artifactId>maven-model</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId> <artifactId>maven-artifact</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>
@ -74,17 +79,17 @@
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-repository-metadata</artifactId> <artifactId>maven-repository-metadata</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId> <artifactId>maven-project</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-registry</artifactId> <artifactId>maven-plugin-registry</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-cli</groupId> <groupId>commons-cli</groupId>
@ -94,12 +99,12 @@
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId> <artifactId>maven-plugin-api</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId> <artifactId>maven-core</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.codehaus.plexus</groupId> <groupId>org.codehaus.plexus</groupId>
@ -109,17 +114,17 @@
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-descriptor</artifactId> <artifactId>maven-plugin-descriptor</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-monitor</artifactId> <artifactId>maven-monitor</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-artifact-manager</artifactId> <artifactId>maven-artifact-manager</artifactId>
<version>2.0-beta-4-SNAPSHOT</version> <version>${mavenVersion}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.maven.wagon</groupId> <groupId>org.apache.maven.wagon</groupId>

View File

@ -22,6 +22,7 @@ import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
import org.apache.maven.artifact.repository.DefaultArtifactRepository; import org.apache.maven.artifact.repository.DefaultArtifactRepository;
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout; import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
import org.apache.maven.artifact.resolver.ArtifactResolutionException; import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
import org.apache.maven.artifact.manager.WagonManager; import org.apache.maven.artifact.manager.WagonManager;
import org.apache.maven.model.Model; import org.apache.maven.model.Model;
import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
@ -42,10 +43,10 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder; import org.apache.maven.plugin.descriptor.PluginDescriptorBuilder;
import org.apache.maven.execution.ReactorManager; import org.apache.maven.execution.ReactorManager;
import org.apache.maven.execution.MavenSession; import org.apache.maven.execution.MavenSession;
import org.apache.maven.execution.MavenExecutionResponse;
import org.apache.maven.monitor.event.EventDispatcher; import org.apache.maven.monitor.event.EventDispatcher;
import org.apache.maven.monitor.event.DefaultEventDispatcher; import org.apache.maven.monitor.event.DefaultEventDispatcher;
import org.apache.maven.monitor.event.EventMonitor; import org.apache.maven.monitor.event.EventMonitor;
import org.apache.maven.BuildFailureException;
import org.codehaus.classworlds.ClassWorld; import org.codehaus.classworlds.ClassWorld;
import org.codehaus.classworlds.DuplicateRealmException; import org.codehaus.classworlds.DuplicateRealmException;
import org.codehaus.plexus.PlexusContainerException; import org.codehaus.plexus.PlexusContainerException;
@ -71,6 +72,7 @@ import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.Collections; import java.util.Collections;
import java.util.Properties; import java.util.Properties;
import java.util.Date;
/** /**
* Class intended to be used by clients who wish to embed Maven into their applications * Class intended to be used by clients who wish to embed Maven into their applications
@ -286,13 +288,13 @@ public class MavenEmbedder
} }
public MavenProject readProjectWithDependencies( File mavenProject, TransferListener transferListener ) public MavenProject readProjectWithDependencies( File mavenProject, TransferListener transferListener )
throws ProjectBuildingException, ArtifactResolutionException throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException
{ {
return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager, transferListener ); return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager, transferListener );
} }
public MavenProject readProjectWithDependencies( File mavenProject ) public MavenProject readProjectWithDependencies( File mavenProject )
throws ProjectBuildingException, ArtifactResolutionException throws ProjectBuildingException, ArtifactResolutionException, ArtifactNotFoundException
{ {
return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager ); return mavenProjectBuilder.buildWithDependencies( mavenProject, localRepository, profileManager );
} }
@ -378,7 +380,7 @@ public class MavenEmbedder
TransferListener transferListener, TransferListener transferListener,
Properties properties, Properties properties,
File executionRootDirectory ) File executionRootDirectory )
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException throws CycleDetectedException, LifecycleExecutionException, BuildFailureException
{ {
execute( Collections.singletonList( project ), goals, eventMonitor, transferListener, properties, executionRootDirectory ); execute( Collections.singletonList( project ), goals, eventMonitor, transferListener, properties, executionRootDirectory );
} }
@ -389,7 +391,7 @@ public class MavenEmbedder
TransferListener transferListener, TransferListener transferListener,
Properties properties, Properties properties,
File executionRootDirectory ) File executionRootDirectory )
throws CycleDetectedException, LifecycleExecutionException, MojoExecutionException throws CycleDetectedException, LifecycleExecutionException, BuildFailureException
{ {
ReactorManager rm = new ReactorManager( projects ); ReactorManager rm = new ReactorManager( projects );
@ -410,7 +412,8 @@ public class MavenEmbedder
rm, rm,
goals, goals,
executionRootDirectory.getAbsolutePath(), executionRootDirectory.getAbsolutePath(),
properties); properties,
new Date() );
session.setUsingPOMsFromFilesystem( true ); session.setUsingPOMsFromFilesystem( true );
@ -438,14 +441,7 @@ public class MavenEmbedder
} }
} }
MavenExecutionResponse response = lifecycleExecutor.execute( session, lifecycleExecutor.execute( session, rm, session.getEventDispatcher() );
rm,
session.getEventDispatcher() );
if ( response.isExecutionFailure() )
{
throw new MojoExecutionException( "Project failed to build.", response.getException() );
}
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
@ -461,7 +457,7 @@ public class MavenEmbedder
PlexusConfiguration configuration = descriptor.getConfiguration(); PlexusConfiguration configuration = descriptor.getConfiguration();
PlexusConfiguration[] phasesConfigurations = configuration.getChild( "phases" ).getChildren( "phase" ); PlexusConfiguration[] phasesConfigurations = configuration.getChild( "lifecycles" ).getChild( 0 ).getChild( "phases" ).getChildren( "phase" );
try try
{ {
@ -528,15 +524,6 @@ public class MavenEmbedder
runtimeInfo.setPluginUpdateOverride( Boolean.FALSE ); runtimeInfo.setPluginUpdateOverride( Boolean.FALSE );
} }
if ( checkLatestPluginVersion )
{
runtimeInfo.setCheckLatestPluginVersion( Boolean.TRUE );
}
else
{
runtimeInfo.setCheckLatestPluginVersion( Boolean.FALSE );
}
return runtimeInfo; return runtimeInfo;
} }

View File

@ -614,6 +614,7 @@
<implementation>org.apache.maven.usability.InvalidArtifactDiagnoser</implementation> <implementation>org.apache.maven.usability.InvalidArtifactDiagnoser</implementation>
</component> </component>
<!-- <!--
| |
| Lifecycle executor | Lifecycle executor
@ -629,50 +630,74 @@
<requirement> <requirement>
<role>org.apache.maven.extension.ExtensionManager</role> <role>org.apache.maven.extension.ExtensionManager</role>
</requirement> </requirement>
<!--
<requirement>
<role>org.apache.maven.project.injection.ModelDefaultsInjector</role>
</requirement>
-->
<requirement> <requirement>
<role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role> <role>org.apache.maven.artifact.handler.manager.ArtifactHandlerManager</role>
</requirement> </requirement>
</requirements> </requirements>
<configuration> <configuration>
<!-- START SNIPPET: lifecyle --> <lifecycles>
<phases> <lifecycle>
<phase implementation="java.lang.String">validate</phase> <id>default</id>
<phase implementation="java.lang.String">initialize</phase> <!-- START SNIPPET: lifecycle -->
<phase implementation="java.lang.String">generate-sources</phase> <phases>
<phase implementation="java.lang.String">process-sources</phase> <phase>validate</phase>
<phase implementation="java.lang.String">generate-resources</phase> <phase>initialize</phase>
<phase implementation="java.lang.String">process-resources</phase> <phase>generate-sources</phase>
<phase implementation="java.lang.String">compile</phase> <phase>process-sources</phase>
<phase implementation="java.lang.String">process-classes</phase> <phase>generate-resources</phase>
<phase implementation="java.lang.String">generate-test-sources</phase> <phase>process-resources</phase>
<phase implementation="java.lang.String">process-test-sources</phase> <phase>compile</phase>
<phase implementation="java.lang.String">generate-test-resources</phase> <phase>process-classes</phase>
<phase implementation="java.lang.String">process-test-resources</phase> <phase>generate-test-sources</phase>
<phase implementation="java.lang.String">test-compile</phase> <phase>process-test-sources</phase>
<phase implementation="java.lang.String">test</phase> <phase>generate-test-resources</phase>
<phase implementation="java.lang.String">package</phase> <phase>process-test-resources</phase>
<phase implementation="java.lang.String">integration-test</phase> <phase>test-compile</phase>
<phase implementation="java.lang.String">verify</phase> <phase>test</phase>
<phase implementation="java.lang.String">install</phase> <phase>package</phase>
<phase implementation="java.lang.String">deploy</phase> <phase>integration-test</phase>
</phases> <phase>verify</phase>
<!-- END SNIPPET: lifecycle --> <phase>install</phase>
<phase>deploy</phase>
</phases>
<!-- END SNIPPET: lifecycle -->
</lifecycle>
<lifecycle>
<id>clean</id>
<phases>
<phase>pre-clean</phase>
<phase>clean</phase>
<phase>post-clean</phase>
</phases>
<default-phases>
<clean>org.apache.maven.plugins:maven-clean-plugin:clean</clean>
</default-phases>
</lifecycle>
<lifecycle>
<id>site</id>
<phases>
<phase>pre-site</phase>
<phase>site</phase>
<phase>post-site</phase>
<phase>site-deploy</phase>
</phases>
<default-phases>
<site>org.apache.maven.plugins:maven-site-plugin:site</site>
<site-deploy>org.apache.maven.plugins:maven-site-plugin:deploy</site-deploy>
</default-phases>
</lifecycle>
</lifecycles>
<!-- START SNIPPET: default-reports --> <!-- START SNIPPET: default-reports -->
<defaultReports> <defaultReports>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-project-info-reports-plugin</report> <report>org.apache.maven.plugins:maven-project-info-reports-plugin</report>
<!-- TODO: currently in mojo - should they be defaults any more? <!-- TODO: currently in mojo - should they be defaults any more?
<report implementation="java.lang.String">org.apache.maven.plugins:maven-checkstyle-plugin</report> <report>org.apache.maven.plugins:maven-checkstyle-plugin</report>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-javadoc-plugin</report> <report>org.apache.maven.plugins:maven-javadoc-plugin</report>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-changelog-plugin</report> <report>org.apache.maven.plugins:maven-changelog-plugin</report>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-surefire-report-plugin</report> <report>org.apache.maven.plugins:maven-surefire-report-plugin</report>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-jdepend-plugin</report> <report>org.apache.maven.plugins:maven-jdepend-plugin</report>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-jxr-plugin</report> <report>org.apache.maven.plugins:maven-jxr-plugin</report>
<report implementation="java.lang.String">org.apache.maven.plugins:maven-taglist-plugin</report> <report>org.apache.maven.plugins:maven-taglist-plugin</report>
--> -->
</defaultReports> </defaultReports>
<!-- END SNIPPET: default-reports --> <!-- END SNIPPET: default-reports -->
@ -855,9 +880,6 @@
<requirement> <requirement>
<role>org.apache.maven.artifact.factory.ArtifactFactory</role> <role>org.apache.maven.artifact.factory.ArtifactFactory</role>
</requirement> </requirement>
<requirement>
<role>org.codehaus.plexus.components.inputhandler.InputHandler</role>
</requirement>
<requirement> <requirement>
<role>org.apache.maven.project.MavenProjectBuilder</role> <role>org.apache.maven.project.MavenProjectBuilder</role>
</requirement> </requirement>
@ -886,7 +908,6 @@
<implementation>org.codehaus.plexus.components.inputhandler.DefaultInputHandler</implementation> <implementation>org.codehaus.plexus.components.inputhandler.DefaultInputHandler</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy> <instantiation-strategy>per-lookup</instantiation-strategy>
</component> </component>
</components> </components>
</component-set> </component-set>

View File

@ -113,7 +113,7 @@ public class MavenEmbedderTest
public void testRetrievingLifecyclePhases() public void testRetrievingLifecyclePhases()
throws Exception throws Exception
{ {
List phases = maven.getLifecyclePhases(); List phases = maven.getLifecyclePhases();
assertEquals( "validate", (String) phases.get( 0 ) ); assertEquals( "validate", (String) phases.get( 0 ) );
@ -129,8 +129,6 @@ public class MavenEmbedderTest
public void testLocalRepositoryRetrieval() public void testLocalRepositoryRetrieval()
throws Exception throws Exception
{ {
System.out.println( "maven.getLocalRepository() = " + maven.getLocalRepository() );
assertNotNull( maven.getLocalRepository().getBasedir() ); assertNotNull( maven.getLocalRepository().getBasedir() );
} }
@ -163,8 +161,6 @@ public class MavenEmbedderTest
assertEquals( 1, artifacts.size() ); assertEquals( 1, artifacts.size() );
Artifact artifact = (Artifact) artifacts.iterator().next(); Artifact artifact = (Artifact) artifacts.iterator().next();
System.out.println( "artifact.getFile().getAbsolutePath() = " + artifact.getFile().getAbsolutePath() );
} }
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------