Title: [746] trunk/plugins/maven/src/it: JBEHAVE-90: Allow optional scope parameter to allow goals to be run in test scope.
Revision
746
Author
mauro
Date
2007-07-11 04:57:14 -0500 (Wed, 11 Jul 2007)

Log Message

JBEHAVE-90:  Allow optional scope parameter to allow goals to be run in test scope.

Modified Paths

Added Paths

Diff

Modified: trunk/plugins/maven/src/it/pom.xml (745 => 746)

--- trunk/plugins/maven/src/it/pom.xml	2007-07-11 08:39:11 UTC (rev 745)
+++ trunk/plugins/maven/src/it/pom.xml	2007-07-11 09:57:14 UTC (rev 746)
@@ -7,12 +7,13 @@
 	<artifactId>jbehave-maven-plugin-it</artifactId>
 	<version>1.1-SNAPSHOT</version>
 	<packaging>pom</packaging>
-	<name>jBehave Maven Plugin Integration Test Reactor</name>
+	<name>jBehave Maven Plugin Integration Tests</name>
 
 	<modules>
         <module>test1</module>
         <module>test2</module>
         <module>test3</module>
+        <module>test4</module>
 	</modules>
 
 </project>

Added: trunk/plugins/maven/src/it/src/test/java/org/jbehave/it/SampleBehaviourTest.java (0 => 746)

--- trunk/plugins/maven/src/it/src/test/java/org/jbehave/it/SampleBehaviourTest.java	                        (rev 0)
+++ trunk/plugins/maven/src/it/src/test/java/org/jbehave/it/SampleBehaviourTest.java	2007-07-11 09:57:14 UTC (rev 746)
@@ -0,0 +1,12 @@
+package org.jbehave.it;
+
+public class SampleBehaviourTest extends junit.framework.TestCase {
+
+    public void testNothing(){
+        // keep junit happy
+    }
+    
+    public void shouldDoSomethingInTestScope() {
+        System.out.println("Done something in test scope");
+    }
+}

Added: trunk/plugins/maven/src/it/src/test/java/org/jbehave/it/TestBehaviours.java (0 => 746)

--- trunk/plugins/maven/src/it/src/test/java/org/jbehave/it/TestBehaviours.java	                        (rev 0)
+++ trunk/plugins/maven/src/it/src/test/java/org/jbehave/it/TestBehaviours.java	2007-07-11 09:57:14 UTC (rev 746)
@@ -0,0 +1,14 @@
+package org.jbehave.it;
+
+import org.jbehave.core.behaviour.Behaviours;
+
+public class TestBehaviours implements Behaviours {
+
+    public Class[] getBehaviours() {
+        return new Class[] {
+                org.jbehave.it.SampleBehaviourTest.class
+        };
+    }
+}
+
+

Added: trunk/plugins/maven/src/it/test4/pom.xml (0 => 746)

--- trunk/plugins/maven/src/it/test4/pom.xml	                        (rev 0)
+++ trunk/plugins/maven/src/it/test4/pom.xml	2007-07-11 09:57:14 UTC (rev 746)
@@ -0,0 +1,49 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>org.jbehave</groupId>
+	<artifactId>jbehave-maven-plugin-it-test4</artifactId>
+	<version>1.1-SNAPSHOT</version>
+	<packaging>jar</packaging>
+	<name>jBehave Maven Plugin Integration Test 4</name>
+
+	<dependencies>
+		<dependency>
+			<groupId>${pom.groupId}</groupId>
+			<artifactId>jbehave</artifactId>
+			<version>${pom.version}</version>
+		</dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>3.8.2</version>
+            <scope>test</scope>
+        </dependency>
+	</dependencies>
+	
+	<build>
+		<testSourceDirectory>${basedir}/../src/test</testSourceDirectory>
+		<plugins>
+			<plugin>
+				<groupId>org.jbehave</groupId>
+				<artifactId>jbehave-maven-plugin</artifactId>
+				<executions>				
+					<execution>
+						<id>run-behaviours</id>
+						<phase>integration-test</phase>
+						<configuration>
+							<behavioursClassName>org.jbehave.it.TestBehaviours</behavioursClassName>
+                            <scope>test</scope>
+						</configuration>		
+						<goals>
+							<goal>run-behaviours</goal>
+						</goals>
+					</execution>
+				</executions>
+			</plugin>				
+		</plugins>
+	</build>
+
+</project>

Modified: trunk/plugins/maven/src/main/java/org/jbehave/mojo/AbstractJBehaveMojo.java (745 => 746)

--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/AbstractJBehaveMojo.java	2007-07-11 08:39:11 UTC (rev 745)
+++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/AbstractJBehaveMojo.java	2007-07-11 09:57:14 UTC (rev 746)
@@ -11,6 +11,8 @@
  */
 public abstract class AbstractJBehaveMojo extends AbstractMojo {
     
+    private static final String TEST_SCOPE = "test";
+
     /**
      * Compile classpath.
      *
@@ -18,7 +20,32 @@
      * @required
      * @readonly
      */
-    List classpathElements;
+    protected List compileClasspathElements;
     
+    /**
+     * Test classpath.
+     *
+     * @parameter _expression_="${project.testClasspathElements}"
+     * @required
+     * @readonly
+     */
+    protected List testClasspathElements;
    
+    /**
+     * The scope of the mojo classpath
+     *
+     * @parameter default-value="compile" 
+     */
+    protected String scope;
+    
+    /**
+     * Returns the compile or test classpath elements based on the scope
+     * @return A List of classpath elements
+     */
+    protected List getClasspathElements(){
+        if ( TEST_SCOPE.equals(scope) ){
+            return testClasspathElements;
+        }
+        return compileClasspathElements;
+    }
 }

Modified: trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java (745 => 746)

--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java	2007-07-11 08:39:11 UTC (rev 745)
+++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java	2007-07-11 09:57:14 UTC (rev 746)
@@ -19,7 +19,7 @@
      * @parameter
      * @required true
      */
-    String behavioursClassName;
+    private String behavioursClassName;
     
     private BehaviourRunner runner = new BehaviourRunner(System.out);
     
@@ -37,7 +37,7 @@
     }
 
     private Behaviours loadBehaviours(String name) throws MalformedURLException, InstantiationException, IllegalAccessException {        
-        BehavioursClassLoader cl = new BehavioursClassLoader(classpathElements);
+        BehavioursClassLoader cl = new BehavioursClassLoader(getClasspathElements());
         return cl.newBehaviours(name);
     }
 

Modified: trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryPrinterMojo.java (745 => 746)

--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryPrinterMojo.java	2007-07-11 08:39:11 UTC (rev 745)
+++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryPrinterMojo.java	2007-07-11 09:57:14 UTC (rev 746)
@@ -20,13 +20,13 @@
      * @parameter
      * @required true
      */
-    String storyPath;
+    private String storyPath;
 
     /**
      * @parameter
      * @required true
      */
-    String storyPackage;
+    private String storyPackage;
 
     /** The story parser */
     private StoryParser storyParser = new TextStoryParser();
@@ -34,7 +34,7 @@
     public void execute() throws MojoExecutionException, MojoFailureException {
         try {
             getLog().debug("Printing story "+ storyPath);
-            StoryLoader loader = new StoryLoader(storyParser, new BehavioursClassLoader(classpathElements));
+            StoryLoader loader = new StoryLoader(storyParser, new BehavioursClassLoader(getClasspathElements()));
             StoryPrinter storyPrinter = new StoryPrinter(loader, new PlainTextRenderer(System.out));            
             storyPrinter.print(storyPath, storyPackage);
         } catch (Exception e) {

Modified: trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java (745 => 746)

--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java	2007-07-11 08:39:11 UTC (rev 745)
+++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java	2007-07-11 09:57:14 UTC (rev 746)
@@ -20,13 +20,13 @@
      * @parameter
      * @required true
      */
-    String storyPath;
+    private String storyPath;
 
     /**
      * @parameter
      * @required true
      */
-    String storyPackage;
+    private String storyPackage;
 
     /** The story parser */
     private StoryParser storyParser = new TextStoryParser();
@@ -37,7 +37,7 @@
     public void execute() throws MojoExecutionException, MojoFailureException {
         try {
             getLog().debug("Running story "+ storyPath);
-            StoryLoader loader = new StoryLoader(storyParser, new BehavioursClassLoader(classpathElements));
+            StoryLoader loader = new StoryLoader(storyParser, new BehavioursClassLoader(getClasspathElements()));
             Story story = loader.loadStory(storyPath, storyPackage);
 			story.specify();
             storyRunner.run(story);


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to