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