From e7e70cb97f0071e8b66ffa0e3e242bae10b04d9d Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Mon, 26 Sep 2005 22:49:03 +0000 Subject: [PATCH] o adding a test which shows that a project can be built from the embedder, now we need to work on the events and logging. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@291775 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/embedder/MavenEmbedder.java | 8 +++++--- .../maven/embedder/MavenEmbedderTest.java | 17 +++++++++++++++-- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java index 57f2512b98..3479a943c6 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java @@ -278,9 +278,7 @@ public class MavenEmbedder rm.setFailureBehavior( ReactorManager.FAIL_AT_END ); - // The first project is blacklisted? - - rm.blackList( (MavenProject) projects.get( 0 ) ); + //rm.blackList( (MavenProject) projects.get( 0 ) ); MavenSession session = new MavenSession( embedder.getContainer(), settings, @@ -290,6 +288,8 @@ public class MavenEmbedder goals, executionRootDirectory.getAbsolutePath() ); + session.setUsingPOMsFromFilesystem( true ); + MavenExecutionResponse response = lifecycleExecutor.execute( session, rm, session.getEventDispatcher() ); @@ -384,6 +384,8 @@ public class MavenEmbedder artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup( ArtifactRepositoryFactory.ROLE ); + lifecycleExecutor = (LifecycleExecutor) embedder.lookup( LifecycleExecutor.ROLE ); + // ---------------------------------------------------------------------- // If an explicit local repository has not been set then we will use the // setting builder to use the maven defaults to help us find one. diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java index 1e7ae6246e..f822512674 100644 --- a/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderTest.java @@ -4,10 +4,13 @@ import junit.framework.TestCase; import org.apache.maven.model.Model; import org.apache.maven.project.MavenProject; import org.apache.maven.artifact.Artifact; +import org.apache.maven.monitor.event.EventDispatcher; +import org.apache.maven.monitor.event.DefaultEventDispatcher; +import org.codehaus.plexus.util.FileUtils; import java.io.File; -import java.util.List; import java.util.Set; +import java.util.Collections; public class MavenEmbedderTest extends TestCase @@ -53,9 +56,19 @@ public class MavenEmbedderTest public void testPhaseExecution() throws Exception { - File pomFile = new File( basedir, "src/test/embedder-test-project/pom.xml" ); + File testDirectory = new File( basedir, "src/test/embedder-test-project" ); + + File targetDirectory = new File( basedir, "target/embedder-test-project" ); + + FileUtils.copyDirectoryStructure( testDirectory, targetDirectory ); + + File pomFile = new File( targetDirectory, "pom.xml" ); MavenProject pom = maven.readProjectWithDependencies( pomFile ); + + EventDispatcher eventDispatcher = new DefaultEventDispatcher(); + + maven.execute( pom, Collections.singletonList( "package" ), eventDispatcher, targetDirectory ); } // ----------------------------------------------------------------------