001    /**************************************************************************************
002     * Copyright (C) 2009 Progress Software, Inc. All rights reserved.                    *
003     * http://fusesource.com                                                              *
004     * ---------------------------------------------------------------------------------- *
005     * The software in this package is published under the terms of the AGPL license      *
006     * a copy of which has been included with this distribution in the license.txt file.  *
007     **************************************************************************************/
008    package org.fusesource.mvnplugins.graph;
009    
010    import org.apache.maven.project.MavenProject;
011    
012    import java.util.ArrayList;
013    import java.util.List;
014    import java.io.File;
015    
016    /**
017     * Generates a graph image of the aggregate dependencies all the projects in
018     * current reactor (aka multi project) build using the graphviz
019     * tool 'dot'.  You must have the 'dot' executable installed and in your path
020     * before using this goal.
021     * <p/>
022     *
023     * @author chirino
024     * @goal reactor
025     * @aggregator
026     * @requiresDependencyResolution compile|test|runtime
027     */
028    public class ReactorMojo extends ProjectMojo {
029    
030        /**
031         * @readonly
032         * @parameter default-value="${reactorProjects}"
033         * @since 1.0
034         */
035        private List<MavenProject> reactorProjects;
036    
037    
038        /**
039         * The file the diagram will be written to.  Must use a file extension that the dot command supports or just the
040         * '.dot' extension.
041         * <br/>
042         * @parameter default-value="${project.build.directory}/reactor-graph.png" expression="${graph.target}"
043         */
044        private File target;
045    
046        @Override
047        protected void collectProjects(ArrayList<MavenProject> projects) {
048            super.collectProjects(projects);
049            if (reactorProjects != null) {
050                projects.addAll(reactorProjects);
051            }
052        }
053    
054        @Override
055        public File getTarget() {
056            return target;
057        }
058    }