Title: [962] trunk/jbehave-ant/src/main/java/org/jbehave/ant: Updated scenario task to not create classpath elements from commandline, as it uses taskdef's classpathref.
Revision
962
Author
mauro
Date
2008-10-02 07:27:37 -0500 (Thu, 02 Oct 2008)

Log Message

Updated scenario task to not create classpath elements from commandline, as it uses taskdef's classpathref.
Replaced in scenario mojo the use of compile/test classpath elements with runtime classpath elements, which is the combined classpath based on the dependency scopes.  
Updated FIXME comment to track progress on classloading issues. 

Modified Paths

Diff

Modified: trunk/examples/trader/src/main/java/org/jbehave/examples/trader/container/TraderContainer.java (961 => 962)

--- trunk/examples/trader/src/main/java/org/jbehave/examples/trader/container/TraderContainer.java	2008-10-02 11:00:43 UTC (rev 961)
+++ trunk/examples/trader/src/main/java/org/jbehave/examples/trader/container/TraderContainer.java	2008-10-02 12:27:37 UTC (rev 962)
@@ -3,9 +3,12 @@
 import org.jbehave.container.pico.XMLPicoContainer;
 
 
-//FIXME there are classloading issues (only using maven plugin) if TraderContainer extends the XMLPicoContainer cointained in core
-//If the scenarios are run as Ant tasks, injecting in the taskdef the maven.runtime.classpath, it works fine
-//Not quite sure what the root cause is - need more investigation. 
+//FIXME there are classloading issues (using maven plugin) if TraderContainer extends the XMLPicoContainer cointained in core
+//while it's got no issues to load a class in this module (eg XMLContainer) which uses the same dependencies as XMLPicoContainer
+//NOTE: If the scenarios are run as Ant tasks, injecting in the taskdef the maven.runtime.classpath, it works fine
+//The difference is that the taskdef uses the Ant classloader Delegate (cf org.apache.tools.ant.util.ClasspathUtils#Delegate) 
+//and not the ScenarioClassLoader constructed from the specified classpath elements
+//TODO understand the difference in the classloaders created
 public class TraderContainer extends XMLPicoContainer {
 
     public TraderContainer(ClassLoader classLoader) {

Modified: trunk/jbehave-ant/src/main/java/org/jbehave/ant/AbstractScenarioTask.java (961 => 962)

--- trunk/jbehave-ant/src/main/java/org/jbehave/ant/AbstractScenarioTask.java	2008-10-02 11:00:43 UTC (rev 961)
+++ trunk/jbehave-ant/src/main/java/org/jbehave/ant/AbstractScenarioTask.java	2008-10-02 12:27:37 UTC (rev 962)
@@ -1,7 +1,7 @@
 package org.jbehave.ant;
 
 import static java.util.Arrays.asList;
-import static org.apache.tools.ant.Project.*;
+import static org.apache.tools.ant.Project.MSG_INFO;
 
 import java.net.MalformedURLException;
 import java.util.ArrayList;
@@ -9,8 +9,6 @@
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.CommandlineJava;
-import org.apache.tools.ant.types.Path;
 import org.jbehave.scenario.RunnableScenario;
 import org.jbehave.scenario.ScenarioClassLoader;
 import org.jbehave.scenario.parser.ScenarioClassNameFinder;
@@ -58,16 +56,16 @@
     private ScenarioClassNameFinder finder = new ScenarioClassNameFinder();
 
     /**
-     * Determines if the scope of the source is "test"
+     * Determines if the scope of the source directory is "test"
      * 
      * @return A boolean <code>true</code> if test scoped
      */
-    private boolean isTestScope() {
+    private boolean isSourceTestScope() {
         return TEST_SCOPE.equals(scope);
     }
 
     private String rootSourceDirectory() {
-        if (isTestScope()) {
+        if (isSourceTestScope()) {
             return testSourceDirectory;
         }
         return sourceDirectory;
@@ -92,10 +90,7 @@
     }
 
     private List<String> classpathElements() {
-        CommandlineJava commandLine = new CommandlineJava();
-        Path path = commandLine.createClasspath(getProject());
-        List<String> classpathElements = asList(path.list());
-        log("Created classpath with elements " + classpathElements, MSG_DEBUG);
+        List<String> classpathElements = asList();
         return classpathElements;
     }
 

Modified: trunk/jbehave-maven-plugin/src/main/java/org/jbehave/mojo/AbstractScenarioMojo.java (961 => 962)

--- trunk/jbehave-maven-plugin/src/main/java/org/jbehave/mojo/AbstractScenarioMojo.java	2008-10-02 11:00:43 UTC (rev 961)
+++ trunk/jbehave-maven-plugin/src/main/java/org/jbehave/mojo/AbstractScenarioMojo.java	2008-10-02 12:27:37 UTC (rev 962)
@@ -66,39 +66,30 @@
     private List<String> scenarioExcludes;
 
     /**
-     * Compile classpath.
+     * Runtime classpath
      * 
-     * @parameter _expression_="${project.compileClasspathElements}"
+     * @parameter _expression_="${project.runtimeClasspathElements}"
      * @required
      * @readonly
      */
-    private List<String> compileClasspathElements;
+    private List<String> runtimeClasspathElements;
 
     /**
-     * Test classpath.
-     * 
-     * @parameter _expression_="${project.testClasspathElements}"
-     * @required
-     * @readonly
-     */
-    private List<String> testClasspathElements;
-
-    /**
      * Used to find scenario class names
      */
     private ScenarioClassNameFinder finder = new ScenarioClassNameFinder();
 
     /**
-     * Determines if the scope of the mojo classpath is "test"
+     * Determines if the scope of the source directory is "test"
      * 
      * @return A boolean <code>true</code> if test scoped
      */
-    private boolean isTestScope() {
+    private boolean isSourceTestScope() {
         return TEST_SCOPE.equals(scope);
     }
 
     private String rootSourceDirectory() {
-        if (isTestScope()) {
+        if (isSourceTestScope()) {
             return testSourceDirectory;
         }
         return sourceDirectory;
@@ -123,10 +114,7 @@
     }
 
     private List<String> classpathElements() {
-        List<String> classpathElements = compileClasspathElements;
-        if (isTestScope()) {
-            classpathElements = testClasspathElements;
-        }
+        List<String> classpathElements = runtimeClasspathElements;
         return classpathElements;
     }
 


To unsubscribe from this list please visit:

http://xircles.codehaus.org/manage_email

Reply via email to