maven-surefire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pg...@apache.org
Subject svn commit: r806311 - /maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
Date Thu, 20 Aug 2009 19:16:16 GMT
Author: pgier
Date: Thu Aug 20 19:16:15 2009
New Revision: 806311

URL: http://svn.apache.org/viewvc?rev=806311&view=rev
Log:
[SUREFIRE-502] Fixing classpath ordering for configured classes/test-classes directories are
used.  Removing a couple of unnecessary @required tags.

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

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=806311&r1=806310&r2=806311&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
Thu Aug 20 19:16:15 2009
@@ -116,23 +116,22 @@
      * System.getProperty("basedir").
      *
      * @parameter expression="${basedir}"
-     * @required
      */
     private File basedir;
 
     /**
      * The directory containing generated test classes of the project being tested.
+     * This will be included at the beginning the test classpath.
      *
-     * @parameter expression="${project.build.testOutputDirectory}"
-     * @required
+     * @parameter default-value="${project.build.testOutputDirectory}"
      */
     private File testClassesDirectory;
 
     /**
      * The directory containing generated classes of the project being tested.
+     * This will be included after the test classes in the test classpath.
      *
-     * @parameter expression="${project.build.outputDirectory}"
-     * @required
+     * @parameter default-value="${project.build.outputDirectory}"
      */
     private File classesDirectory;
 
@@ -837,21 +836,40 @@
         //
         // ----------------------------------------------------------------------
 
-        getLog().debug( "Test Classpath :" );
-
         // 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()
) )
+        File projectClassesDirectory = new File ( project.getBuild().getOutputDirectory()
);
+        if ( ! projectClassesDirectory.equals( classesDirectory ) )
         {
-            classpathElements.remove( project.getBuild().getOutputDirectory() );
-            classpathElements.add( classesDirectory.getAbsolutePath() );
+            int indexToReplace = classpathElements.indexOf( project.getBuild().getOutputDirectory()
);
+            if ( indexToReplace != -1 )
+            {
+                classpathElements.remove( indexToReplace );
+                classpathElements.add( indexToReplace, classesDirectory.getAbsolutePath()
);
+            }
+            else
+            {
+                classpathElements.add( 1, classesDirectory.getAbsolutePath() );
+            }
         }
-        if ( !project.getBuild().getTestOutputDirectory().equals( testClassesDirectory.getAbsolutePath()
) )
+
+        File projectTestClassesDirectory = new File( project.getBuild().getTestOutputDirectory()
);
+        if ( !projectTestClassesDirectory.equals( testClassesDirectory ) )
         {
-            classpathElements.remove( project.getBuild().getTestOutputDirectory() );
-            classpathElements.add( testClassesDirectory.getAbsolutePath() );
+            int indexToReplace = classpathElements.indexOf( project.getBuild().getTestOutputDirectory()
);
+            if ( indexToReplace != -1 )
+            {
+                classpathElements.remove( indexToReplace );
+                classpathElements.add( indexToReplace, testClassesDirectory.getAbsolutePath()
);
+            }
+            else
+            {
+                classpathElements.add( 0, testClassesDirectory.getAbsolutePath() );
+            }
         }
 
+        getLog().debug( "Test Classpath :" );
+
         for ( Iterator i = classpathElements.iterator(); i.hasNext(); )
         {
             String classpathElement = (String) i.next();
@@ -977,6 +995,11 @@
 
         return surefireBooter;
     }
+    
+    /*private void replaceListItem( List list, Object item1, Object item2 )
+    {
+        list.r
+    }*/
 
     private void showMap( Map map, String setting )
     {



Mime
View raw message