001    package org.apache.maven.lifecycle;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.util.Collections;
023    import java.util.LinkedHashSet;
024    import java.util.Set;
025    
026    import org.apache.maven.model.Plugin;
027    import org.apache.maven.model.PluginExecution;
028    
029    /**
030     * @author Benjamin Bentmann
031     */
032    public class EmptyLifecyclePluginAnalyzer
033        implements LifeCyclePluginAnalyzer
034    {
035        public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
036        {
037            Set<Plugin> plugins;
038    
039            // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
040            if ( "JAR".equals( packaging ) )
041            {
042                plugins = new LinkedHashSet<Plugin>();
043    
044                plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
045                plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
046                plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
047                plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
048                plugins.add( newPlugin( "maven-install-plugin", "install" ) );
049                plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
050            }
051            else
052            {
053                plugins = Collections.emptySet();
054            }
055    
056            return plugins;
057        }
058    
059        private Plugin newPlugin( String artifactId, String... goals )
060        {
061            Plugin plugin = new Plugin();
062    
063            plugin.setGroupId( "org.apache.maven.plugins" );
064            plugin.setArtifactId( artifactId );
065    
066            for ( String goal : goals )
067            {
068                PluginExecution pluginExecution = new PluginExecution();
069                pluginExecution.setId( "default-" + goal );
070                pluginExecution.addGoal( goal );
071                plugin.addExecution( pluginExecution );
072            }
073    
074            return plugin;
075        }
076    
077    }