brett 2004/11/05 23:26:33
Modified: src/java/main/org/apache/maven/jelly/tags/maven Tag:
MAVEN-1_0_1-BRANCH ReactorTag.java
Log:
formatting, commenting
Revision Changes Path
No revision
No revision
1.40.2.1 +96 -62
maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/ReactorTag.java
Index: ReactorTag.java
===================================================================
RCS file:
/home/cvs/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/ReactorTag.java,v
retrieving revision 1.40
retrieving revision 1.40.2.1
diff -u -r1.40 -r1.40.2.1
--- ReactorTag.java 28 May 2004 00:59:00 -0000 1.40
+++ ReactorTag.java 6 Nov 2004 07:26:33 -0000 1.40.2.1
@@ -23,6 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.maven.MavenConstants;
+import org.apache.maven.MavenException;
import org.apache.maven.MavenUtils;
import org.apache.maven.project.Project;
@@ -35,7 +36,7 @@
/**
* Reactor tag that processes a set of project descriptors taking into
* consideration the inter-project dependencies.
- *
+ * <p/>
* Used for building a set of projects in the correct order to satisfy any
* dependencies among the projects being processed.
*
@@ -51,30 +52,45 @@
{
private static final Log log = LogFactory.getLog( ReactorTag.class );
- /** The glob used to select projects within the base directory. */
+ /**
+ * The glob used to select projects within the base directory.
+ */
private String glob;
- /** Projects to include. */
+ /**
+ * Projects to include.
+ */
private String includes;
- /** Projects to exclude. */
+ /**
+ * Projects to exclude.
+ */
private String excludes;
- /** Banner to display when each project is processed. */
+ /**
+ * Banner to display when each project is processed.
+ */
private String banner;
- /** project base directory */
+ /**
+ * project base directory
+ */
private File basedir;
-
- /** The name of the context variable to store the project collection in. */
+
+ /**
+ * The name of the context variable to store the project collection in.
+ */
private String collectionVar = "reactorProjects";
-
- /** Whether to actually execute the default or specified goals, or
+
+ /**
+ * Whether to actually execute the default or specified goals, or
* simply collect the projects in order.
*/
private boolean collectOnly = false;
- /** Whether to sort the projects by dependencies. */
+ /**
+ * Whether to sort the projects by dependencies.
+ */
private boolean sort = true;
/**
@@ -83,10 +99,14 @@
*/
private boolean postProcessing = false;
- /** Storage for projects that failed in the build. */
+ /**
+ * Storage for projects that failed in the build.
+ */
private Collection failedProjects = new ArrayList();
- /** List of Project objects to use instead of glob or includes. */
+ /**
+ * List of Project objects to use instead of glob or includes.
+ */
private List projectList = null;
// ----------------------------------------------------------------------
@@ -95,6 +115,7 @@
/**
* Set the project list.
+ *
* @param projectList the project list
*/
public void setProjectList( List projectList )
@@ -104,6 +125,7 @@
/**
* Get the project list.
+ *
* @return the project list
*/
public List getProjectList()
@@ -114,6 +136,7 @@
/**
* Setter for the basedir property
* XXX if the method it overrides is deprecated, is this also deprecated?
+ *
* @param basedir the base directory for execution of the project
*/
public void setBasedir( File basedir )
@@ -130,33 +153,35 @@
{
return this.basedir;
}
-
+
public void setSort( boolean sort )
{
this.sort = sort;
}
-
- /** Set the collectOnly attribute. This controls whether reactor
- * will actually execute any goals on the projects, or simply
+
+ /**
+ * Set the collectOnly attribute. This controls whether reactor
+ * will actually execute any goals on the projects, or simply
* collect the sorted set of projects included in this reactor
* invocation.
- *
- * @param collectOnly if true, don't execute project goals; simply
- * gather the sorted project collection and store. Otherwise,
- * operate as before (execute either specified goals or default goal
- * for each project).
+ *
+ * @param collectOnly if true, don't execute project goals; simply
+ * gather the sorted project collection and store. Otherwise,
+ * operate as before (execute either specified goals or
default goal
+ * for each project).
*/
public void setCollectOnly( boolean collectOnly )
{
this.collectOnly = collectOnly;
}
-
- /** Set the collectionVar attribute. This controls the context
+
+ /**
+ * Set the collectionVar attribute. This controls the context
* variable which will contain the sorted set of projects included
* in this reactor invocation.
- *
+ *
* @param collectionVar The context variable for the project collection
- * discovered here.
+ * discovered here.
*/
public void setCollectionVar( String collectionVar )
{
@@ -273,7 +298,7 @@
}
/**
- * Execute the body of the reactor tag.
+ * Execute the body of the reactor tag.
*
* @param output The output sink.
* @throws JellyTagException If an error occurs while processing the tag.
@@ -302,7 +327,7 @@
log.info( "Our processing order:" );
- for ( Iterator i = sortedProjects.iterator(); i.hasNext();)
+ for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
{
Project p = (Project) i.next();
log.info( p.getName() );
@@ -311,47 +336,50 @@
ArrayList reactorProjects = new ArrayList();
Runtime r = Runtime.getRuntime();
- for ( Iterator i = sortedProjects.iterator(); i.hasNext();)
+ for ( Iterator i = sortedProjects.iterator(); i.hasNext(); )
{
// The basedir needs to be set for the project
// We just need the descriptor.
Project project = (Project) i.next();
- beforeProject(project);
- try
+ beforeProject( project );
+
+ final long mb = 1024 * 1024;
+ log.info( "+----------------------------------------" );
+ log.info( "| " + getBanner() + " " + project.getName() );
+ log.info( "| Memory: " + ( ( r.totalMemory() - r.freeMemory() ) / mb )
+ "M/" + ( r.totalMemory() / mb ) + "M" );
+ log.info( "+----------------------------------------" );
+
+ // We only try to attain goals if they have been set. The reactor
+ // might be in use to collect project information for the purpose
+ // of, say, generating a sites from a set of components.
+ List goalList = null;
+ if ( getGoals() != null )
{
- final long mb = 1024 * 1024;
- log.info( "+----------------------------------------" );
- log.info( "| " + getBanner() + " " + project.getName() );
- log.info( "| Memory: " + ((r.totalMemory() - r.freeMemory()) / mb)
+ "M/" + (r.totalMemory() / mb) + "M");
- log.info( "+----------------------------------------" );
-
- // We only try to attain goals if they have been set. The reactor
- // might be in use to collect project information for the purpose
- // of, say, generating a sites from a set of components.
- List goalList = null;
- if ( getGoals() != null )
- {
- goalList = MavenUtils.getGoalListFromCsv( getGoals() );
- }
+ goalList = MavenUtils.getGoalListFromCsv( getGoals() );
+ }
- beforeLaunchGoals( project );
-
- if( !collectOnly )
+ beforeLaunchGoals( project );
+
+ try
+ {
+ if ( !collectOnly )
{
getMavenContext().getMavenSession().attainGoals( project,
goalList );
}
-
- afterLaunchGoals( project );
}
catch ( Exception e )
{
onException( project, e );
+ // TODO: there is a risk that continuing may leave the project in
an inconsistent state.
+ // -- attainGoals needs to split fatal from non-fatal exceptions
and we only ignore non-fatal
if ( !isIgnoreFailures() )
{
throw new JellyTagException( "Reactor subproject failure
occurred", e );
}
}
+
+ afterLaunchGoals( project );
afterProject( project );
if ( getPostProcessing() || collectOnly )
@@ -361,7 +389,7 @@
}
getContext().setVariable( collectionVar, reactorProjects );
- Collection c = ( Collection ) getContext().getVariable(
MavenConstants.FAILED_PROJECTS );
+ Collection c = (Collection) getContext().getVariable(
MavenConstants.FAILED_PROJECTS );
if ( c == null )
{
c = new ArrayList( failedProjects );
@@ -376,10 +404,10 @@
/**
* Get a list of projects to process, sorted by dependency processing order.
* Maintained as a separate method so that the original projects and dependency
resolver memory is freed.
+ *
* @return the project list
- * @throws Exception FIXME this is bad
*/
- private List getSortedProjects() throws Exception
+ private List getSortedProjects() throws MavenException
{
if ( projectList != null )
{
@@ -398,7 +426,7 @@
}
List projects = MavenUtils.getProjects( getBasedir(), projectIncludes,
getExcludes(),
- getMavenContext().getMavenSession().getRootContext() );
+
getMavenContext().getMavenSession().getRootContext() );
if ( sort )
{
@@ -415,43 +443,48 @@
/**
* This method is running before launching a project.
+ *
* @param project the currentProject
*/
- public void beforeProject(Project project)
+ public void beforeProject( Project project )
{
}
/**
* This method is running before launching project goals.
+ *
* @param project the currentProject
*/
- public void beforeLaunchGoals(Project project)
+ public void beforeLaunchGoals( Project project )
{
}
/**
* This method is running after launching project goals.
+ *
* @param project the currentProject
*/
- public void afterLaunchGoals(Project project)
+ public void afterLaunchGoals( Project project )
{
}
/**
* This method is running after launching a project.
+ *
* @param project the currentProject
*/
- public void afterProject(Project project)
+ public void afterProject( Project project )
{
}
/**
* This method is running when an exception occurs whatever
* the ignoreFailures value.
+ *
* @param project the currentProject
- * @param e the exception
+ * @param e the exception
*/
- public void onException(Project project, Exception e)
+ public void onException( Project project, Exception e )
{
getMavenContext().setVariable( MavenConstants.BUILD_FAILURE, "true" );
failedProjects.add( project );
@@ -460,9 +493,10 @@
/**
* This method is running when an exception occurs in
* dependency resolution.
+ *
* @param e the exception
*/
- public void onDependencyResolutionException(Exception e)
+ public void onDependencyResolutionException( Exception e )
{
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]