From 967c2533b98da571fb1e9e860196f7f7e7fa07f1 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Wed, 28 Feb 2007 19:02:06 +0000 Subject: [PATCH] MNG-2051 The SCM plugin which uses the scm manager works fine. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@512903 13f79535-47bb-0310-9956-ffa450edef68 --- maven-embedder/src/site/apt/index.apt | 4 +- .../AbstractEmbedderExecutionTestCase.java | 45 ++++++++++++++----- .../embedder/EmbedderUsingScmPluginTest.java | 28 ++++++++++++ 3 files changed, 65 insertions(+), 12 deletions(-) create mode 100644 maven-embedder/src/test/java/org/apache/maven/embedder/EmbedderUsingScmPluginTest.java diff --git a/maven-embedder/src/site/apt/index.apt b/maven-embedder/src/site/apt/index.apt index 9d15fcd596..efc8a43eff 100644 --- a/maven-embedder/src/site/apt/index.apt +++ b/maven-embedder/src/site/apt/index.apt @@ -32,12 +32,14 @@ A Note on Configuring Settings * Plugin Groups + [] + If you are using the embedder it is entirely your responsibility to take user and global settings information and specify it in the embedder configuration. The embedder carries with it <<>> defaults about where these are located and how they are used. If you want your embedded use of Maven to mimic the behavior of the Maven CLI insofar as settings use then use the following code: - %{snippet|id=mimic-cli|url=http://svn.apache.org/repos/asf/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderExampleTest.java} +%{snippet|id=mimic-cli|url=http://svn.apache.org/repos/asf/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderExampleTest.java} Also note that the user and global settings are merged, and the user settings are dominant. diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderExecutionTestCase.java b/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderExecutionTestCase.java index c4132855d1..accfa0ba28 100644 --- a/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderExecutionTestCase.java +++ b/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderExecutionTestCase.java @@ -9,32 +9,46 @@ import java.io.File; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Properties; public abstract class AbstractEmbedderExecutionTestCase extends AbstractEmbedderTestCase { - protected MavenExecutionRequest request( File basedir, - List goals ) - { - return new DefaultMavenExecutionRequest() - .setBaseDirectory( basedir ) - .setGoals( goals ); - } - protected File runWithProject( String goal ) throws Exception { - return runWithProject( new String[]{goal} ); + return runWithProject( goal, null ); + } + + protected File runWithProject( String goal, + Properties properties ) + throws Exception + { + return runWithProject( new String[]{goal}, properties ); } protected File runWithProject( String[] goals ) throws Exception { - return runWithProject( Arrays.asList( goals ) ); + return runWithProject( goals, null ); + } + + protected File runWithProject( String[] goals, + Properties properties ) + throws Exception + { + return runWithProject( Arrays.asList( goals ), properties ); } protected File runWithProject( List goals ) throws Exception + { + return runWithProject( goals, null ); + } + + protected File runWithProject( List goals, + Properties properties ) + throws Exception { /* if ( request.getBaseDirectory() == null || !new File( request.getBaseDirectory() ).exists() ) @@ -49,7 +63,16 @@ public abstract class AbstractEmbedderExecutionTestCase FileUtils.copyDirectoryStructure( testDirectory, targetDirectory ); - MavenExecutionRequest request = request( targetDirectory, goals ); + MavenExecutionRequest request = new DefaultMavenExecutionRequest() + .setBaseDirectory( targetDirectory ) + .setGoals( goals ); + + System.out.println( "properties = " + properties ); + + if ( properties != null ) + { + request.setProperties( properties ); + } MavenExecutionResult result = maven.execute( request ); diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/EmbedderUsingScmPluginTest.java b/maven-embedder/src/test/java/org/apache/maven/embedder/EmbedderUsingScmPluginTest.java new file mode 100644 index 0000000000..f4a17fb4c8 --- /dev/null +++ b/maven-embedder/src/test/java/org/apache/maven/embedder/EmbedderUsingScmPluginTest.java @@ -0,0 +1,28 @@ +package org.apache.maven.embedder; + +import java.io.File; +import java.util.Properties; + +/** @author Jason van Zyl */ +public class EmbedderUsingScmPluginTest + extends AbstractEmbedderExecutionTestCase +{ + protected String getId() + { + return "scm-plugin-from-embedder"; + } + + public void testRunningScmPlugin() + throws Exception + { + Properties p = new Properties(); + + File outputDirectory = new File( getBasedir(), "target/scm.diff" ); + + p.setProperty( "outputDirectory", outputDirectory.getCanonicalPath() ); + + p.setProperty( "connectionUrl", "scm:svn:http://svn.apache.org/repos/asf/maven/components/trunk/maven-embedder" ); + + File basedir = runWithProject( "scm:diff", p ); + } +}