brett 2004/11/06 13:57:32 Modified: . project.xml src/java/main/org/apache/maven/jelly/tags/maven DependencyResolver.java DependencyResolverInterface.java GraphDependencyResolver.java ReactorTag.java WerkzDependencyResolver.java xdocs changes.xml Added: src/java/main/org/apache/maven/jelly/tags/maven DependencyResolverException.java Log: merge MAVEN-1_0_1-BRANCH up to MAVEN_JELLY_TAGS_1_0_1 Revision Changes Path 1.7 +5 -0 maven-jelly-tags/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/maven-jelly-tags/project.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- project.xml 21 Sep 2004 13:45:45 -0000 1.6 +++ project.xml 6 Nov 2004 21:57:32 -0000 1.7 @@ -235,5 +235,10 @@ <name>1.0</name> <tag>MAVEN_JELLY_TAGS-1_0</tag> </version> + <version> + <id>1.0.1</id> + <name>1.0.1</name> + <tag>MAVEN_JELLY_TAGS_1_0_1</tag> + </version> </versions> </project> 1.8 +20 -18 maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/DependencyResolver.java Index: DependencyResolver.java =================================================================== RCS file: /home/cvs/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/DependencyResolver.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- DependencyResolver.java 23 Mar 2004 02:18:19 -0000 1.7 +++ DependencyResolver.java 6 Nov 2004 21:57:32 -0000 1.8 @@ -35,35 +35,37 @@ * Creates the dependency resolver. The implementation is chosen by the * System property "maven.core.dependencyresolver". By default it is * the WerkzDependencyResolver. Ultimately I see this proxy being removed. + * * @see java.lang.Object#Object() */ public DependencyResolver() { String prop = "maven.core.dependencyresolver"; - String type = System.getProperty(prop); + String type = System.getProperty( prop ); try { - if (type == null) + if ( type == null ) { impl = new WerkzDependencyResolver(); } else { - impl = (DependencyResolverInterface) Class.forName(type).newInstance(); + impl = (DependencyResolverInterface) Class.forName( type ).newInstance(); } } - catch (Exception e) + catch ( Exception e ) { - throw new RuntimeException("Unable to create " + type); + throw new RuntimeException( "Unable to create " + type ); } } /** * Creates the dependency resolver with a specific implementation + * * @param impl */ - public DependencyResolver(DependencyResolverInterface impl) + public DependencyResolver( DependencyResolverInterface impl ) { this.impl = impl; } @@ -79,42 +81,42 @@ /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#setProjects(java.util.List) */ - public void setProjects(List projects) + public void setProjects( List projects ) { - impl.setProjects(projects); + impl.setProjects( projects ); } /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(org.apache.maven.project.Project) */ - public List getSortedDependencies(Project project) throws Exception + public List getSortedDependencies( Project project ) throws DependencyResolverException { - return impl.getSortedDependencies(project); + return impl.getSortedDependencies( project ); } /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(org.apache.maven.project.Project, boolean) */ - public List getSortedDependencies(Project project, boolean sourceBuild) throws Exception + public List getSortedDependencies( Project project, boolean sourceBuild ) throws DependencyResolverException { - return impl.getSortedDependencies(project, sourceBuild); + return impl.getSortedDependencies( project, sourceBuild ); } /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(boolean) */ - public List getSortedDependencies(boolean sourceBuild) throws Exception + public List getSortedDependencies( boolean sourceBuild ) throws DependencyResolverException { - return impl.getSortedDependencies(sourceBuild); + return impl.getSortedDependencies( sourceBuild ); } - public static Project getProject(List projects, String id) + public static Project getProject( List projects, String id ) { Iterator iter = projects.iterator(); - while (iter.hasNext()) + while ( iter.hasNext() ) { Project project = (Project) iter.next(); - if (project.getId().equals(id)) + if ( project.getId().equals( id ) ) { return project; } 1.6 +9 -9 maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/DependencyResolverInterface.java Index: DependencyResolverInterface.java =================================================================== RCS file: /home/cvs/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/DependencyResolverInterface.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- DependencyResolverInterface.java 23 Mar 2004 02:18:19 -0000 1.5 +++ DependencyResolverInterface.java 6 Nov 2004 21:57:32 -0000 1.6 @@ -37,33 +37,33 @@ * * @param projects List of projects. */ - void setProjects(List projects); + void setProjects( List projects ); /** * Get the list of projects in dependency sorted order. * * @param project The project to use as the head of the graph. * @return The list of projects. - * @throws Exception If an error occurs while processing the graph. + * @throws DependencyResolverException If an error occurs while processing the graph. */ - List getSortedDependencies(Project project) throws Exception; + List getSortedDependencies( Project project ) throws DependencyResolverException; /** * Get the list of projects in dependency sorted order. * - * @param project The project to use as the head of the graph. + * @param project The project to use as the head of the graph. * @param sourceBuild Indicate we are performing a source build. * @return The list of projects. - * @throws Exception If an error occurs while processing the graph. + * @throws DependencyResolverException If an error occurs while processing the graph. */ - List getSortedDependencies(Project project, boolean sourceBuild) throws Exception; + List getSortedDependencies( Project project, boolean sourceBuild ) throws DependencyResolverException; /** * Get the list of projects in dependency sorted order. * * @param sourceBuild Flag to indicate we are performing a source build. * @return The list of projects. - * @throws Exception If an error occurs while processing the graph. + * @throws DependencyResolverException If an error occurs while processing the graph. */ - List getSortedDependencies(boolean sourceBuild) throws Exception; + List getSortedDependencies( boolean sourceBuild ) throws DependencyResolverException; } 1.5 +36 -30 maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/GraphDependencyResolver.java Index: GraphDependencyResolver.java =================================================================== RCS file: /home/cvs/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/GraphDependencyResolver.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- GraphDependencyResolver.java 23 Mar 2004 02:18:19 -0000 1.4 +++ GraphDependencyResolver.java 6 Nov 2004 21:57:32 -0000 1.5 @@ -25,23 +25,29 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; + /** - * Takes a list of maven projects and determines the overall - * dependency ordering among the project. + * Takes a list of maven projects and determines the overall + * dependency ordering among the project. * * @author <a href="mailto:[EMAIL PROTECTED]">Jason van Zyl</a> - * * @version $Id$ */ public class GraphDependencyResolver implements DependencyResolverInterface { - /** The dependency graph. */ + /** + * The dependency graph. + */ private DependencyGraph dependencyGraph; - /** List of maven projects to analyse. */ + /** + * List of maven projects to analyse. + */ private List projects; - /** Flag to indicate whether the graph has been built. */ + /** + * Flag to indicate whether the graph has been built. + */ private boolean graphBuilt; /** @@ -66,7 +72,7 @@ /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#setProjects(List) */ - public void setProjects(List projects) + public void setProjects( List projects ) { this.projects = projects; } @@ -74,42 +80,42 @@ /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(Project) */ - public List getSortedDependencies(Project project) throws Exception + public List getSortedDependencies( Project project ) { - return getSortedDependencies(project, false); + return getSortedDependencies( project, false ); } /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(Project, boolean) */ - public List getSortedDependencies(Project project, boolean sourceBuild) throws Exception + public List getSortedDependencies( Project project, boolean sourceBuild ) { buildGraph(); - List sortedDependencies = dependencyGraph.getSortedDependencies(project); + List sortedDependencies = dependencyGraph.getSortedDependencies( project ); - if (sourceBuild) + if ( sourceBuild ) { return sortedDependencies; } - return getBinaryDependencies(sortedDependencies); + return getBinaryDependencies( sortedDependencies ); } /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(boolean) */ - public List getSortedDependencies(boolean sourceBuild) throws Exception + public List getSortedDependencies( boolean sourceBuild ) { buildGraph(); List sortedDependencies = dependencyGraph.getSortedDependencies(); - if (sourceBuild) + if ( sourceBuild ) { return sortedDependencies; } - return getBinaryDependencies(sortedDependencies); + return getBinaryDependencies( sortedDependencies ); } /** @@ -118,24 +124,24 @@ * @param sortedDependencies List of projects that have been dependency sorted. * @return The list of projects. */ - private List getBinaryDependencies(List sortedDependencies) + private List getBinaryDependencies( List sortedDependencies ) { HashMap idMap = new HashMap(); - for (Iterator i = projects.iterator(); i.hasNext();) + for ( Iterator i = projects.iterator(); i.hasNext(); ) { Project p = (Project) i.next(); - idMap.put(p.getId(), p); + idMap.put( p.getId(), p ); } List binaryDeps = new ArrayList(); - for (Iterator i = sortedDependencies.iterator(); i.hasNext();) + for ( Iterator i = sortedDependencies.iterator(); i.hasNext(); ) { Project p = (Project) i.next(); - Project dep = (Project) idMap.get(p.getId()); - if (dep != null) + Project dep = (Project) idMap.get( p.getId() ); + if ( dep != null ) { - binaryDeps.add(dep); + binaryDeps.add( dep ); } } @@ -147,25 +153,25 @@ */ private void buildGraph() { - if (graphBuilt) + if ( graphBuilt ) { return; } - for (Iterator i = projects.iterator(); i.hasNext();) + for ( Iterator i = projects.iterator(); i.hasNext(); ) { Project p = (Project) i.next(); ArrayList dependencies = new ArrayList(); - for (Iterator j = p.getDependencies().iterator(); j.hasNext();) + for ( Iterator j = p.getDependencies().iterator(); j.hasNext(); ) { Dependency d = (Dependency) j.next(); Project dependentProject = new Project(); - dependentProject.setId(d.getId()); - dependencies.add(dependentProject); + dependentProject.setId( d.getId() ); + dependencies.add( dependentProject ); } - dependencyGraph.addDependencies(p, dependencies); + dependencyGraph.addDependencies( p, dependencies ); } graphBuilt = true; } 1.42 +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.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- ReactorTag.java 18 Sep 2004 01:02:14 -0000 1.41 +++ ReactorTag.java 6 Nov 2004 21:57:32 -0000 1.42 @@ -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 ) { getContext().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 ) { } } 1.11 +90 -53 maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/WerkzDependencyResolver.java Index: WerkzDependencyResolver.java =================================================================== RCS file: /home/cvs/maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/WerkzDependencyResolver.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- WerkzDependencyResolver.java 26 Jun 2004 15:00:42 -0000 1.10 +++ WerkzDependencyResolver.java 6 Nov 2004 21:57:32 -0000 1.11 @@ -18,10 +18,12 @@ */ import com.werken.werkz.Action; +import com.werken.werkz.CyclicGoalChainException; import com.werken.werkz.Goal; +import com.werken.werkz.NoActionDefinitionException; import com.werken.werkz.Session; +import com.werken.werkz.UnattainableGoalException; import com.werken.werkz.WerkzProject; - import org.apache.maven.project.Dependency; import org.apache.maven.project.Project; @@ -31,6 +33,7 @@ /** * THIS CLASS IS NOT THREADSAFE. + * * @author <a href="mailto:[EMAIL PROTECTED]">Ben Walding</a> * @version $Id$ */ @@ -54,7 +57,7 @@ /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#setProjects(java.util.List) */ - public void setProjects(List projects) + public void setProjects( List projects ) { this.projects = projects; } @@ -62,16 +65,17 @@ /** * Retrieves the existing goal for a project (based on Id). * If no goal exists, an exception is thrown. + * * @param project the project to retrieve a goal from * @return ProjectGoal */ - protected ProjectGoal getExistingGoal(Project project) + protected ProjectGoal getExistingGoal( Project project ) { - ProjectGoal goal = (ProjectGoal) wproject.getGoal(project.getId()); + ProjectGoal goal = (ProjectGoal) wproject.getGoal( project.getId() ); - if (goal == null) + if ( goal == null ) { - throw new NullPointerException("No goal exists : " + project.getId()); + throw new NullPointerException( "No goal exists : " + project.getId() ); } else { @@ -82,29 +86,29 @@ /** * Retrieves the existing goal for a project (based on Id). * If no goal exists, one is created for this given project. + * * @param project * @param sourceBuild * @return ProjectGoal */ - protected ProjectGoal getOrCreateGoal(Project project, boolean sourceBuild) + protected ProjectGoal getOrCreateGoal( Project project, boolean sourceBuild ) { - ProjectGoal goal = (ProjectGoal) wproject.getGoal(project.getId()); - if (goal == null) + ProjectGoal goal = (ProjectGoal) wproject.getGoal( project.getId() ); + if ( goal == null ) { - goal = new ProjectGoal(project, sourceBuild); - goal.setAction(new ListAddAction(goal, sortedGoals)); - wproject.addGoal(goal); + goal = new ProjectGoal( project, sourceBuild ); + goal.setAction( new ListAddAction( goal, sortedGoals ) ); + wproject.addGoal( goal ); } return goal; } /** * Builds the projects / dependencies into an internal acyclic directed graph - * @throws Exception */ - public void buildGraph() throws Exception + public void buildGraph() throws CyclicGoalChainException { - if (doItAll != null) + if ( doItAll != null ) { return; } @@ -113,38 +117,38 @@ { wproject = new WerkzProject(); - doItAll = new Goal("DO_IT_ALL"); - doItAll.setAction(new DummyAction()); + doItAll = new Goal( "DO_IT_ALL" ); + doItAll.setAction( new DummyAction() ); //Initialise all the true goals of the system Iterator iter = projects.iterator(); - while (iter.hasNext()) + while ( iter.hasNext() ) { Project project = (Project) iter.next(); - Goal projectGoal = getOrCreateGoal(project, true); - doItAll.addPrecursor(projectGoal); + Goal projectGoal = getOrCreateGoal( project, true ); + doItAll.addPrecursor( projectGoal ); } //Now add the dependencies iter = projects.iterator(); - while (iter.hasNext()) + while ( iter.hasNext() ) { Project project = (Project) iter.next(); - Goal projectGoal = getExistingGoal(project); + Goal projectGoal = getExistingGoal( project ); Iterator depIter = project.getDependencies().iterator(); - while (depIter.hasNext()) + while ( depIter.hasNext() ) { Dependency dep = (Dependency) depIter.next(); Project depProject = new Project(); - depProject.setId(dep.getId()); + depProject.setId( dep.getId() ); - Goal depGoal = getOrCreateGoal(depProject, false); - projectGoal.addPrecursor(depGoal); + Goal depGoal = getOrCreateGoal( depProject, false ); + projectGoal.addPrecursor( depGoal ); } } } - catch (Exception e) + catch ( CyclicGoalChainException e ) { doItAll = null; wproject = new WerkzProject(); @@ -156,31 +160,32 @@ /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(org.apache.maven.project.Project) */ - public List getSortedDependencies(Project project) throws Exception + public List getSortedDependencies( Project project ) throws DependencyResolverException { - return getSortedDependencies(project, false); + return getSortedDependencies( project, false ); } /** * Filters the given list of goals, and returns the associated projects - * + * <p/> * If param:sourceBuild == true, include goal * If param:sourceBuild == false, include goal if goal:sourceBuild == true + * * @param goals * @param sourceBuild * @return List */ - public List getProjects(List goals, boolean sourceBuild) + public List getProjects( List goals, boolean sourceBuild ) { List result = new ArrayList(); Iterator iter = goals.iterator(); - while (iter.hasNext()) + while ( iter.hasNext() ) { ProjectGoal goal = (ProjectGoal) iter.next(); - if ((sourceBuild) || (!sourceBuild && goal.getSourceBuild())) + if ( ( sourceBuild ) || ( !sourceBuild && goal.getSourceBuild() ) ) { - result.add((goal).getProject()); + result.add( ( goal ).getProject() ); } } @@ -190,27 +195,57 @@ /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(org.apache.maven.project.Project, boolean) */ - public List getSortedDependencies(Project project, boolean sourceBuild) throws Exception + public List getSortedDependencies( Project project, boolean sourceBuild ) throws DependencyResolverException { - buildGraph(); - sortedGoals.clear(); - Session session = new Session(); - ProjectGoal g = getExistingGoal(project); - g.attain(session); + try + { + buildGraph(); + sortedGoals.clear(); + Session session = new Session(); + ProjectGoal g = getExistingGoal( project ); + g.attain( session ); + } + catch ( CyclicGoalChainException e ) + { + throw new DependencyResolverException( "A cycle was detected", e ); + } + catch ( UnattainableGoalException e ) + { + throw new DependencyResolverException( "An invalid goal was called", e ); + } + catch ( NoActionDefinitionException e ) + { + throw new DependencyResolverException( "An invalid goal was called", e ); + } - return getProjects(sortedGoals, sourceBuild); + return getProjects( sortedGoals, sourceBuild ); } /** * @see org.apache.maven.jelly.tags.maven.DependencyResolverInterface#getSortedDependencies(boolean) */ - public List getSortedDependencies(boolean sourceBuild) throws Exception + public List getSortedDependencies( boolean sourceBuild ) throws DependencyResolverException { - buildGraph(); - sortedGoals.clear(); - Session session = new Session(); - doItAll.attain(session); - return getProjects(sortedGoals, sourceBuild); + try + { + buildGraph(); + sortedGoals.clear(); + Session session = new Session(); + doItAll.attain( session ); + return getProjects( sortedGoals, sourceBuild ); + } + catch ( CyclicGoalChainException e ) + { + throw new DependencyResolverException( "A cycle was detected", e ); + } + catch ( UnattainableGoalException e ) + { + throw new DependencyResolverException( "An invalid goal was called", e ); + } + catch ( NoActionDefinitionException e ) + { + throw new DependencyResolverException( "An invalid goal was called", e ); + } } } @@ -222,7 +257,8 @@ { private List list; private Goal goal; - public ListAddAction(Goal goal, List list) + + public ListAddAction( Goal goal, List list ) { this.list = list; this.goal = goal; @@ -235,12 +271,12 @@ public void performAction( Session session ) throws Exception { - list.add(goal); + list.add( goal ); } public void performAction() throws Exception { - list.add(goal); + list.add( goal ); } } @@ -271,9 +307,10 @@ { private final Project project; private final boolean sourceBuild; - public ProjectGoal(Project project, boolean sourceBuild) + + public ProjectGoal( Project project, boolean sourceBuild ) { - super(project.getId()); + super( project.getId() ); this.project = project; this.sourceBuild = sourceBuild; } 1.2 +21 -0 maven-jelly-tags/src/java/main/org/apache/maven/jelly/tags/maven/DependencyResolverException.java 1.4 +10 -6 maven-jelly-tags/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/maven-jelly-tags/xdocs/changes.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- changes.xml 28 May 2004 00:59:01 -0000 1.3 +++ changes.xml 6 Nov 2004 21:57:32 -0000 1.4 @@ -24,17 +24,21 @@ <author email="[EMAIL PROTECTED]">Vincent Massol</author> </properties> <body> - <release version="1.0.1-SNAPSHOT" date="in CVS"> - <action dev="brett" type="update">Improve error reporting in <code>AddPathTag</code>.</action> + <release version="1.1-SNAPSHOT" date="in CVS"> + <action dev="brett" type="update">Start using maven-model for project references</action> + </release> + <release version="1.0.1" date="2004-11-07"> + <action dev="brett" type="update">Improve error reporting in + <code>AddPathTag</code>. + </action> </release> - <release version="1.0" date="2004-05-11"> <action dev="vmassol" type="add">Added new - <code>SetTag</code> tag to set plugin properties + <code>SetTag</code>tag to set plugin properties </action> <action dev="vmassol" type="add">Added new - <code>GetTag</code> tag that replaces the now deprecated - <code>PluginVar</code> tag + <code>GetTag</code>tag that replaces the now deprecated + <code>PluginVar</code>tag </action> <action dev="brett" type="fix" issue="MAVEN-1219">Install and uninstall plugin tags for managing plugins on the fly.</action> <action dev="brett" type="add">Jelly tag library separated from Maven core.</action>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]