maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r594570 - in /maven/surefire/trunk/maven-surefire-plugin: pom.xml src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Date Tue, 13 Nov 2007 16:16:01 GMT
Author: brett
Date: Tue Nov 13 08:16:01 2007
New Revision: 594570

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

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

Modified: maven/surefire/trunk/maven-surefire-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/pom.xml?rev=594570&r1=594569&r2=594570&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/pom.xml (original)
+++ maven/surefire/trunk/maven-surefire-plugin/pom.xml Tue Nov 13 08:16: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/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=594570&r1=594569&r2=594570&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
(original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Tue Nov 13 08:16: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;
@@ -110,6 +111,23 @@
     private File testClassesDirectory;
 
     /**
+     * The directory containing generated classes of the project being tested.
+     *
+     * @parameter expression="${project.build.outputDirectory}"
+     * @required
+     */
+    private File classesDirectory;
+
+    /**
+     * The Maven Project Object
+     *
+     * @parameter expression="${project}"
+     * @required
+     * @readonly
+     */
+    protected MavenProject project;
+
+    /**
      * The classpath elements of the project being tested.
      * 
      * @parameter expression="${project.testClasspathElements}"
@@ -649,7 +667,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(); )
         {



Mime
View raw message