jvanzyl 2004/05/09 16:00:59 Modified: maven-core/src/main/java/org/apache/maven DefaultMavenCore.java Maven.java MavenCli.java MavenCore.java maven-core/src/main/java/org/apache/maven/plugin/descriptor GoalDescriptor.java ParameterDescriptor.java PluginDescriptor.java Added: maven-core/src/main/java/org/apache/maven ReactorException.java Log: o the reactor now works with the -r flag to run over a set of goals for a set of projects, so rudimentary things like: maven -r clean maven -r xdoc work nicely, and now time to add some notions of processing the top-level which in many cases might be aggregation but it could be any arbitrary process really. Revision Changes Path 1.3 +37 -2 maven-components/maven-core/src/main/java/org/apache/maven/DefaultMavenCore.java Index: DefaultMavenCore.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/DefaultMavenCore.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- DefaultMavenCore.java 8 May 2004 21:11:16 -0000 1.2 +++ DefaultMavenCore.java 9 May 2004 23:00:59 -0000 1.3 @@ -26,6 +26,7 @@ import org.apache.maven.project.ProjectBuildingException; import org.codehaus.plexus.PlexusConstants; import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable; import org.codehaus.plexus.context.Context; import org.codehaus.plexus.context.ContextException; @@ -34,6 +35,8 @@ import java.io.File; import java.util.List; import java.util.Map; +import java.util.ArrayList; +import java.util.Iterator; public class DefaultMavenCore implements MavenCore, Contextualizable @@ -59,7 +62,7 @@ private I18N i18n; // ---------------------------------------------------------------------- - // Goal attainment + // Project execution // ---------------------------------------------------------------------- public void execute( String goal ) @@ -69,7 +72,7 @@ } public void execute( File projectFile, String goal ) - throws ProjectBuildingException,GoalNotFoundException + throws ProjectBuildingException, GoalNotFoundException { execute( getProject( projectFile ), goal ); } @@ -89,6 +92,38 @@ catch ( Exception e ) { e.printStackTrace(); + } + } + + // ---------------------------------------------------------------------- + // Reactor execution + // ---------------------------------------------------------------------- + + public void executeReactor( String goal ) + throws ReactorException, GoalNotFoundException + { + List projects = new ArrayList(); + + try + { + List files = FileUtils.getFiles( + new File( System.getProperty( "user.dir" ) ), "**/project.xml,**/project2.xml", "project.xml,project2.xml" ); + + for ( Iterator iterator = files.iterator(); iterator.hasNext(); ) + { + projects.add( projectBuilder.build( (File) iterator.next() ) ); + } + + projects = projectBuilder.getSortedProjects( projects ); + } + catch ( Exception e ) + { + throw new ReactorException( "Error processing projects for the reactor: ", e ); + } + + for ( Iterator iterator = projects.iterator(); iterator.hasNext(); ) + { + execute( (MavenProject) iterator.next(), goal ); } } 1.13 +16 -1 maven-components/maven-core/src/main/java/org/apache/maven/Maven.java Index: Maven.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/Maven.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- Maven.java 8 May 2004 10:11:18 -0000 1.12 +++ Maven.java 9 May 2004 23:00:59 -0000 1.13 @@ -46,6 +46,7 @@ if ( bootClassWorld == null ) { classWorld = new ClassWorld(); + classWorld.newRealm( "core", embedder.getClass().getClassLoader() ); } else @@ -64,6 +65,10 @@ maven = (MavenCore) embedder.lookup( MavenCore.ROLE ); } + // ---------------------------------------------------------------------- + // Project execution + // ---------------------------------------------------------------------- + public void execute( String goal ) throws GoalNotFoundException { @@ -80,6 +85,16 @@ throws GoalNotFoundException { maven.execute( project, goal ); + } + + // ---------------------------------------------------------------------- + // Reactor execution + // ---------------------------------------------------------------------- + + public void executeReactor( String goal ) + throws ReactorException,GoalNotFoundException + { + maven.executeReactor( goal ); } // ---------------------------------------------------------------------- 1.4 +13 -5 maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java Index: MavenCli.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCli.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- MavenCli.java 7 May 2004 17:59:46 -0000 1.3 +++ MavenCli.java 9 May 2004 23:00:59 -0000 1.4 @@ -26,9 +26,7 @@ import org.codehaus.classworlds.ClassWorld; import java.io.File; -import java.io.FileInputStream; import java.util.Iterator; -import java.util.Properties; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> @@ -81,9 +79,19 @@ // Execute the goals // ---------------------------------------------------------------------- - for ( Iterator i = commandLine.getArgList().iterator(); i.hasNext(); ) + if ( commandLine.hasOption( REACTOR ) ) { - maven.execute( projectFile, (String) i.next() ); + for ( Iterator i = commandLine.getArgList().iterator(); i.hasNext(); ) + { + maven.executeReactor( (String) i.next() ); + } + } + else + { + for ( Iterator i = commandLine.getArgList().iterator(); i.hasNext(); ) + { + maven.execute( projectFile, (String) i.next() ); + } } } 1.2 +8 -1 maven-components/maven-core/src/main/java/org/apache/maven/MavenCore.java Index: MavenCore.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/MavenCore.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MavenCore.java 16 Apr 2004 13:56:09 -0000 1.1 +++ MavenCore.java 9 May 2004 23:00:59 -0000 1.2 @@ -50,6 +50,13 @@ throws ProjectBuildingException,GoalNotFoundException; // ---------------------------------------------------------------------- + // Reactor execution + // ---------------------------------------------------------------------- + + void executeReactor( String goal ) + throws ReactorException,GoalNotFoundException; + + // ---------------------------------------------------------------------- // Plugin descriptors // ---------------------------------------------------------------------- 1.1 maven-components/maven-core/src/main/java/org/apache/maven/ReactorException.java Index: ReactorException.java =================================================================== package org.apache.maven; /** * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> * @version $Id: ReactorException.java,v 1.1 2004/05/09 23:00:59 jvanzyl Exp $ */ public class ReactorException extends Exception { public ReactorException() { } public ReactorException( String message ) { super( message ); } public ReactorException( Throwable cause ) { super( cause ); } public ReactorException( String message, Throwable cause ) { super( message, cause ); } } 1.8 +41 -1 maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/GoalDescriptor.java Index: GoalDescriptor.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/GoalDescriptor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- GoalDescriptor.java 8 May 2004 23:34:18 -0000 1.7 +++ GoalDescriptor.java 9 May 2004 23:00:59 -0000 1.8 @@ -16,6 +16,7 @@ * limitations under the License. */ +import java.util.ArrayList; import java.util.List; /** @@ -64,5 +65,44 @@ public String getMethod() { return method; + } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + public void setName( String name ) + { + this.name = name; + } + + public void setParameters( List parameters ) + { + this.parameters = parameters; + } + + public void setPrereqs( List prereqs ) + { + this.prereqs = prereqs; + } + + public void setDescription( String description ) + { + this.description = description; + } + + public void setRequiresDependencyResolution( boolean requiresDependencyResolution ) + { + this.requiresDependencyResolution = requiresDependencyResolution; + } + + public void setRequiresProject( boolean requiresProject ) + { + this.requiresProject = requiresProject; + } + + public void setMethod( String method ) + { + this.method = method; } } 1.3 +20 -1 maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/ParameterDescriptor.java Index: ParameterDescriptor.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/ParameterDescriptor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- ParameterDescriptor.java 21 Mar 2004 00:33:17 -0000 1.2 +++ ParameterDescriptor.java 9 May 2004 23:00:59 -0000 1.3 @@ -45,4 +45,23 @@ { return description; } + + // ---------------------------------------------------------------------- + // + // ---------------------------------------------------------------------- + + public void setName( String name ) + { + this.name = name; + } + + public void setExpression( String expression ) + { + this.expression = expression; + } + + public void setDescription( String description ) + { + this.description = description; + } } 1.6 +20 -0 maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java Index: PluginDescriptor.java =================================================================== RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/plugin/descriptor/PluginDescriptor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- PluginDescriptor.java 22 Mar 2004 18:05:39 -0000 1.5 +++ PluginDescriptor.java 9 May 2004 23:00:59 -0000 1.6 @@ -20,6 +20,7 @@ import org.apache.maven.plugin.Plugin; import java.util.List; +import java.util.ArrayList; public class PluginDescriptor extends ComponentDescriptor @@ -53,5 +54,24 @@ public String getMode() { return mode; + } + + // ---------------------------------------------------------------------- + // Setters used by tools like pluggy + // ---------------------------------------------------------------------- + + public void setId( String id ) + { + this.id = id; + } + + public void setGoals( List goals ) + { + this.goals = goals; + } + + public void setMode( String mode ) + { + this.mode = mode; } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]