Author: brett
Date: Tue Nov 13 08:27:01 2007
New Revision: 594572

URL: http://svn.apache.org/viewvc?rev=594572&view=rev
Log:
[SUREFIRE-333] ensure the correct classes directories are used
Submitted by: Paul Gier
Merged from trunk rev: 594570

Modified:
    maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/pom.xml
    
maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Modified: maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/pom.xml?rev=594572&r1=594571&r2=594572&view=diff
==============================================================================
--- maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/pom.xml 
(original)
+++ maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/pom.xml Tue 
Nov 13 08:27:01 2007
@@ -112,6 +112,11 @@
       <artifactId>maven-artifact</artifactId>
       <version>2.0</version>
     </dependency>
+    <dependency>
+      <groupId>org.apache.maven</groupId>
+      <artifactId>maven-project</artifactId>
+      <version>2.0</version>
+    </dependency>
   </dependencies>
 
   <profiles>

Modified: 
maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: 
http://svn.apache.org/viewvc/maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=594572&r1=594571&r2=594572&view=diff
==============================================================================
--- 
maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 (original)
+++ 
maven/surefire/branches/surefire-2.3.x/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
 Tue Nov 13 08:27:01 2007
@@ -34,6 +34,7 @@
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
 import org.apache.maven.surefire.booter.ForkConfiguration;
 import org.apache.maven.surefire.booter.SurefireBooter;
 import org.apache.maven.surefire.booter.SurefireBooterForkException;
@@ -101,23 +102,30 @@
      */
     private File basedir;
 
-    // FIXME this field is not used - remove it
     /**
-     * The directory containing generated classes of the project being tested.
+     * The directory containing generated test classes of the project being 
tested.
      * 
+     * @parameter expression="${project.build.testOutputDirectory}"
+     * @required
+     */
+    private File testClassesDirectory;
+
+    /**
+     * The directory containing generated classes of the project being tested.
+     *
      * @parameter expression="${project.build.outputDirectory}"
      * @required
-     * @deprecated
      */
     private File classesDirectory;
 
     /**
-     * The directory containing generated test classes of the project being 
tested.
-     * 
-     * @parameter expression="${project.build.testOutputDirectory}"
+     * The Maven Project Object
+     *
+     * @parameter expression="${project}"
      * @required
+     * @readonly
      */
-    private File testClassesDirectory;
+    protected MavenProject project;
 
     /**
      * The classpath elements of the project being tested.
@@ -626,7 +634,18 @@
 
         getLog().debug( "Test Classpath :" );
 
-        // no need to add classes/test classes directory here - they are in 
the classpath elements already
+        // Check if we need to add configured classes/test classes directories 
here.
+        // If they are configured, we should remove the default to avoid 
conflicts.
+        if ( !project.getBuild().getOutputDirectory().equals( 
classesDirectory.getAbsolutePath() ) )
+        {
+            classpathElements.remove( project.getBuild().getOutputDirectory() 
);
+            classpathElements.add( classesDirectory.getAbsolutePath() );
+        }
+        if ( !project.getBuild().getTestOutputDirectory().equals( 
testClassesDirectory.getAbsolutePath() ) )
+        {
+            classpathElements.remove( 
project.getBuild().getTestOutputDirectory() );
+            classpathElements.add( testClassesDirectory.getAbsolutePath() );
+        }
 
         for ( Iterator i = classpathElements.iterator(); i.hasNext(); )
         {


Reply via email to