You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2009/07/28 13:46:04 UTC

svn commit: r798494 - /maven/components/trunk/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java

Author: bentmann
Date: Tue Jul 28 11:46:04 2009
New Revision: 798494

URL: http://svn.apache.org/viewvc?rev=798494&view=rev
Log:
[MNG-2871] Subartifact (ejb-client, test-jar etc.) are not reselved as active project artifacts in build phases prior to package
[MNG-3043] Allow 'mvn test' to work with test-jar dependencies in a reactor

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java?rev=798494&r1=798493&r2=798494&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java Tue Jul 28 11:46:04 2009
@@ -1,5 +1,6 @@
 package org.apache.maven;
 
+import java.io.File;
 import java.util.Collection;
 import java.util.Map;
 
@@ -63,21 +64,28 @@
 
                     artifact.setResolved( true );
                 }
-
-                /*
-                
-                TODO: This is being left out because Maven 2.x does not set this internally and it is only done by the compiler
-                plugin and not done generally. This should be done generally but currently causes problems with MNG-3023
-                
-                else if ( new File( project.getBuild().getOutputDirectory() ).exists() )
+                else
                 {
-                    artifact.setFile( new File( project.getBuild().getOutputDirectory() ) );
+                    File classesDir;
 
-                    artifact.setFromAuthoritativeRepository( true );
+                    if ( isTestArtifact( artifact ) )
+                    {
+                        classesDir = new File( project.getBuild().getTestOutputDirectory() );
+                    }
+                    else
+                    {
+                        classesDir = new File( project.getBuild().getOutputDirectory() );
+                    }
+
+                    if ( classesDir.isDirectory() )
+                    {
+                        artifact.setFile( classesDir );
 
-                    artifact.setResolved( true );
+                        artifact.setFromAuthoritativeRepository( true );
+
+                        artifact.setResolved( true );
+                    }
                 }
-                */
             }
         }
 
@@ -182,6 +190,25 @@
         return buffer.toString();
     }
 
+    /**
+     * Determines whether the specified artifact refers to test classes.
+     * 
+     * @param artifact The artifact to check, must not be {@code null}.
+     * @return {@code true} if the artifact refers to test classes, {@code false} otherwise.
+     */
+    private static boolean isTestArtifact( Artifact artifact )
+    {
+        if ( "test-jar".equals( artifact.getType() ) )
+        {
+            return true;
+        }
+        else if ( "jar".equals( artifact.getType() ) && "tests".equals( artifact.getClassifier() ) )
+        {
+            return true;
+        }
+        return false;
+    }
+
     @Override
     public int hashCode()
     {