001 package org.apache.maven.project;
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.lifecycle.LifeCyclePluginAnalyzer;
027 import org.apache.maven.model.Plugin;
028 import org.apache.maven.model.PluginExecution;
029
030 /**
031 * @author Benjamin Bentmann
032 */
033 public class EmptyLifecyclePluginAnalyzer
034 implements LifeCyclePluginAnalyzer
035 {
036 public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
037 {
038 Set<Plugin> plugins;
039
040 // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
041 if ( "JAR".equals( packaging ) )
042 {
043 plugins = new LinkedHashSet<Plugin>();
044
045 plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
046 plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
047 plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
048 plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
049 plugins.add( newPlugin( "maven-install-plugin", "install" ) );
050 plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
051 }
052 else
053 {
054 plugins = Collections.emptySet();
055 }
056
057 return plugins;
058 }
059
060 private Plugin newPlugin( String artifactId, String... goals )
061 {
062 Plugin plugin = new Plugin();
063
064 plugin.setGroupId( "org.apache.maven.plugins" );
065 plugin.setArtifactId( artifactId );
066
067 for ( String goal : goals )
068 {
069 PluginExecution pluginExecution = new PluginExecution();
070 pluginExecution.setId( "default-" + goal );
071 pluginExecution.addGoal( goal );
072 plugin.addExecution( pluginExecution );
073 }
074
075 return plugin;
076 }
077
078 }