001    /**
002     * Copyright (C) 2009 Progress Software, Inc.
003     * http://fusesource.com
004     * 
005     * Licensed under the Apache License, Version 2.0 (the "License");
006     * you may not use this file except in compliance with the License.
007     * You may obtain a copy of the License at
008     * 
009     *    http://www.apache.org/licenses/LICENSE-2.0
010     * 
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.fusesource.mvnplugins.graph;
018    
019    import org.apache.maven.project.MavenProject;
020    
021    import java.util.ArrayList;
022    import java.util.List;
023    import java.io.File;
024    
025    /**
026     * Generates a graph image of the aggregate dependencies all the projects in
027     * current reactor (aka multi project) build using the graphviz
028     * tool 'dot'.  You must have the 'dot' executable installed and in your path
029     * before using this goal.
030     * <p/>
031     *
032     * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
033     * @goal reactor
034     * @aggregator
035     * @requiresDependencyResolution compile|test|runtime
036     */
037    public class ReactorMojo extends ProjectMojo {
038    
039        /**
040         * @readonly
041         * @parameter default-value="${reactorProjects}"
042         * @since 1.0
043         */
044        private List<MavenProject> reactorProjects;
045    
046    
047        /**
048         * The file the diagram will be written to.  Must use a file extension that the dot command supports or just the
049         * '.dot' extension.
050         * <br/>
051         * @parameter default-value="${project.build.directory}/reactor-graph.png" expression="${graph.target}"
052         */
053        private File target;
054    
055        @Override
056        protected void collectProjects(ArrayList<MavenProject> projects) {
057            super.collectProjects(projects);
058            if (reactorProjects != null) {
059                projects.addAll(reactorProjects);
060            }
061        }
062    
063        @Override
064        public File getTarget() {
065            return target;
066        }
067    }