From d9ac5ea1e5d9ec4c03d315fc27743d340b05f151 Mon Sep 17 00:00:00 2001 From: Brett Leslie Porter Date: Fri, 6 May 2005 08:22:28 +0000 Subject: [PATCH] use consistent ordering for reactored projects git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@168569 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/maven/DefaultMaven.java | 21 ++++++++++++------- .../java/org/apache/maven/cli/MavenCli.java | 3 +++ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index ecf2fa3b58..0eff06608e 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -33,10 +33,10 @@ import org.apache.maven.project.MavenProjectBuilder; import org.apache.maven.project.ProjectBuildingException; import org.apache.maven.project.ProjectSorter; import org.apache.maven.reactor.ReactorException; +import org.apache.maven.settings.Mirror; import org.apache.maven.settings.Proxy; import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; -import org.apache.maven.settings.Mirror; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.repository.exception.ComponentLookupException; @@ -45,8 +45,6 @@ import org.codehaus.plexus.context.ContextException; import org.codehaus.plexus.i18n.I18N; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; -import org.codehaus.plexus.util.FileUtils; -import org.codehaus.plexus.util.StringUtils; import org.codehaus.plexus.util.dag.CycleDetectedException; import java.io.File; @@ -183,14 +181,21 @@ public class DefaultMaven // TODO: Really should fail if it was not? What if it is aggregating - eg "ear"? project.setPackaging( "pom" ); - String includes = StringUtils.join( project.getModules().iterator(), "/pom.xml," ) + "/pom.xml"; + File basedir = file.getParentFile(); - if ( includes.indexOf( ".." ) >= 0 ) + // Initial ordering is as declared in the modules section + List moduleFiles = new ArrayList( project.getModules().size() ); + for ( Iterator i = project.getModules().iterator(); i.hasNext(); ) { - throw new ProjectBuildingException( "Modules may not include '..'" ); + String name = (String) i.next(); + if ( name.indexOf( '/' ) >= 0 ) + { + String message = "Illegal module name: " + name + " (cannot contain path characters)"; + throw new ReactorException( message ); + } + moduleFiles.add( new File( basedir, name + "/pom.xml" ) ); } - List moduleFiles = FileUtils.getFiles( project.getFile().getParentFile(), includes, null ); List collectedProjects = collectProjects( moduleFiles, localRepository, recursive ); projects.addAll( collectedProjects ); project.setCollectedProjects( collectedProjects ); @@ -276,7 +281,7 @@ public class DefaultMaven { if ( pom.length() == 0 ) { - throw new ProjectBuildingException( i18n.format( "empty.descriptor.error", pom.getName() ) ); + throw new ProjectBuildingException( i18n.format( "empty.descriptor.error", pom ) ); } } diff --git a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java index 817f7ac263..5ba88bef63 100644 --- a/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java +++ b/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java @@ -291,6 +291,9 @@ public class MavenCli String excludes = System.getProperty( "maven.reactor.excludes", POMv4 ); files = FileUtils.getFiles( userDir, includes, excludes ); + + // make sure there is consistent ordering on all platforms, rather than using the filesystem ordering + Collections.sort( files ); } else {