- Revision
- 691
- Author
- mauro
- Date
- 2007-02-26 12:12:24 -0600 (Mon, 26 Feb 2007)
Log Message
Added StoryPrinterMojo.
Modified Paths
- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java
- trunk/plugins/maven/src/it/pom.xml
- trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java
- trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java
Added Paths
Diff
Modified: trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java (690 => 691)
--- trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-02-26 17:58:54 UTC (rev 690) +++ trunk/core/src/java/org/jbehave/core/story/StoryPrinter.java 2007-02-26 18:12:24 UTC (rev 691) @@ -29,13 +29,11 @@ public void print(String storyPath, String storyPackage) throws MalformedURLException { Story story = storyLoader.loadStory(storyPath, storyPackage); - story.specify(); story.narrateTo(renderer); } public void print(String storyClassName) throws InstantiationException, IllegalAccessException, ClassNotFoundException{ Story story = storyLoader.loadStory(storyClassName); - story.specify(); story.narrateTo(renderer); }
Modified: trunk/plugins/maven/src/it/pom.xml (690 => 691)
--- trunk/plugins/maven/src/it/pom.xml 2007-02-26 17:58:54 UTC (rev 690) +++ trunk/plugins/maven/src/it/pom.xml 2007-02-26 18:12:24 UTC (rev 691) @@ -12,6 +12,7 @@ <modules> <module>test1</module> <module>test2</module> + <module>test3</module> </modules> </project>
Added: trunk/plugins/maven/src/it/test3/pom.xml (0 => 691)
--- trunk/plugins/maven/src/it/test3/pom.xml (rev 0) +++ trunk/plugins/maven/src/it/test3/pom.xml 2007-02-26 18:12:24 UTC (rev 691) @@ -0,0 +1,51 @@ +<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-test3</artifactId> + <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + <name>jBehave Maven Plugin Integration Test 3</name> + + <dependencies> + <dependency> + <groupId>${pom.groupId}</groupId> + <artifactId>jbehave</artifactId> + <version>${pom.version}</version> + </dependency> + </dependencies> + + <build> + <sourceDirectory>${basedir}/../src/main</sourceDirectory> + <resources> + <resource> + <directory>${basedir}/../src/main/java</directory> + <includes> + <include>**/*.story</include> + </includes> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.jbehave</groupId> + <artifactId>jbehave-maven-plugin</artifactId> + <executions> + <execution> + <id>run-story</id> + <phase>integration-test</phase> + <configuration> + <storyPath>org/jbehave/it/stories/it.story</storyPath> + <storyPackage>org.jbehave.it.stories</storyPackage> + </configuration> + <goals> + <goal>print-story</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + +</project>
Added: trunk/plugins/maven/src/main/java/org/jbehave/mojo/AbstractJBehaveMojo.java (0 => 691)
--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/AbstractJBehaveMojo.java (rev 0) +++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/AbstractJBehaveMojo.java 2007-02-26 18:12:24 UTC (rev 691) @@ -0,0 +1,24 @@ +package org.jbehave.mojo; + +import java.util.List; + +import org.apache.maven.plugin.AbstractMojo; + +/** + * Abstract base class containing common functionality for all JBehave Mojos. + * + * @author Mauro Talevi + */ +public abstract class AbstractJBehaveMojo extends AbstractMojo { + + /** + * Compile classpath. + * + * @parameter _expression_="${project.compileClasspathElements}" + * @required + * @readonly + */ + List classpathElements; + + +}
Modified: trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java (690 => 691)
--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java 2007-02-26 17:58:54 UTC (rev 690) +++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/BehaviourRunnerMojo.java 2007-02-26 18:12:24 UTC (rev 691) @@ -1,9 +1,7 @@ package org.jbehave.mojo; import java.net.MalformedURLException; -import java.util.List; -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.jbehave.core.BehaviourRunner; @@ -15,18 +13,9 @@ * @author Mauro Talevi * @goal run-behaviours */ -public class BehaviourRunnerMojo extends AbstractMojo { +public class BehaviourRunnerMojo extends AbstractJBehaveMojo { /** - * Compile classpath. - * - * @parameter _expression_="${project.compileClasspathElements}" - * @required - * @readonly - */ - List classpathElements; - - /** * @parameter * @required true */
Added: trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryPrinterMojo.java (0 => 691)
--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryPrinterMojo.java (rev 0) +++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryPrinterMojo.java 2007-02-26 18:12:24 UTC (rev 691) @@ -0,0 +1,45 @@ +package org.jbehave.mojo; + +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.jbehave.core.story.StoryLoader; +import org.jbehave.core.story.StoryPrinter; +import org.jbehave.core.story.codegen.parser.StoryParser; +import org.jbehave.core.story.codegen.parser.TextStoryParser; +import org.jbehave.core.story.renderer.PlainTextRenderer; + +/** + * Mojo to print a story + * + * @author Mauro Talevi + * @goal print-story + */ +public class StoryPrinterMojo extends AbstractJBehaveMojo { + + /** + * @parameter + * @required true + */ + String storyPath; + + /** + * @parameter + * @required true + */ + String storyPackage; + + /** The story parser */ + private StoryParser storyParser = new TextStoryParser(); + + public void execute() throws MojoExecutionException, MojoFailureException { + try { + getLog().debug("Printing story "+ storyPath); + StoryLoader loader = new StoryLoader(storyParser, new BehavioursClassLoader(classpathElements)); + StoryPrinter storyPrinter = new StoryPrinter(loader, new PlainTextRenderer(System.out)); + storyPrinter.print(storyPath, storyPackage); + } catch (Exception e) { + throw new MojoExecutionException("Failed to print story "+storyPath+" with package "+storyPackage, e); + } + } + +}
Modified: trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java (690 => 691)
--- trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java 2007-02-26 17:58:54 UTC (rev 690) +++ trunk/plugins/maven/src/main/java/org/jbehave/mojo/StoryRunnerMojo.java 2007-02-26 18:12:24 UTC (rev 691) @@ -1,8 +1,5 @@ package org.jbehave.mojo; -import java.util.List; - -import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.jbehave.core.story.StoryLoader; @@ -17,18 +14,9 @@ * @author Mauro Talevi * @goal run-story */ -public class StoryRunnerMojo extends AbstractMojo { - +public class StoryRunnerMojo extends AbstractJBehaveMojo { + /** - * Compile classpath. - * - * @parameter _expression_="${project.compileClasspathElements}" - * @required - * @readonly - */ - List classpathElements; - - /** * @parameter * @required true */
To unsubscribe from this list please visit:
