maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r505663 - /maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
Date Sat, 10 Feb 2007 09:18:47 GMT
Author: jvanzyl
Date: Sat Feb 10 01:18:46 2007
New Revision: 505663

URL: http://svn.apache.org/viewvc?view=rev&rev=505663
Log:
MNG-2819  Prevent extension scanner from looping infinitely when projects are in a flattened
structure

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

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java?view=diff&rev=505663&r1=505662&r2=505663
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/extension/DefaultBuildExtensionScanner.java
Sat Feb 10 01:18:46 2007
@@ -24,6 +24,7 @@
 import org.codehaus.plexus.logging.console.ConsoleLogger;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -125,17 +126,45 @@
                 
                 getLogger().debug( "Scanning module: " + moduleSubpath );
 
-                File modulePom = new File( basedir, moduleSubpath );
+                File modulePomDirectory;
 
-                if ( modulePom.isDirectory() )
+                try
+                {
+                    modulePomDirectory = new File( basedir, moduleSubpath ).getCanonicalFile();
+
+                    // ----------------------------------------------------------------------------
+                    // We need to make sure we don't loop infinitely in the case where we
have
+                    // something like:
+                    //
+                    // <modules>
+                    //    <module>../MNGECLIPSE-256web</module>
+                    //    <module>../MNGECLIPSE-256utility</module>
+                    // </modules>
+                    //
+                    // Where once we walk into the first module it will just get its parent
dir
+                    // containing its POM over and over again unless we make a comparison
to
+                    // basedir and the modulePomDirectory.
+                    // ----------------------------------------------------------------------------
+
+                    if ( modulePomDirectory.equals( basedir.getCanonicalFile() ) )
+                    {
+                        break;
+                    }
+                }
+                catch ( IOException e )
+                {
+                    throw new ExtensionScanningException( "Error getting canonical path for
modulePomDirectory.",  e );
+                }
+
+                if ( modulePomDirectory.isDirectory() )
                 {
                     getLogger().debug(
                                        "Assuming POM file 'pom.xml' in module: " + moduleSubpath
+ " under basedir: "
                                            + basedir );
-                    modulePom = new File( modulePom, "pom.xml" );
+                    modulePomDirectory = new File( modulePomDirectory, "pom.xml" );
                 }
 
-                if ( !modulePom.exists() )
+                if ( !modulePomDirectory.exists() )
                 {
                     getLogger().debug(
                                        "Cannot find POM for module: " + moduleSubpath
@@ -143,7 +172,7 @@
                     continue;
                 }
 
-                scanForBuildExtensions( modulePom, localRepository, globalProfileManager,
pomFilesById );
+                scanForBuildExtensions( modulePomDirectory, localRepository, globalProfileManager,
pomFilesById );
             }
         }
     }



Mime
View raw message