1   package org.apache.maven.project;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Collections;
23  import java.util.LinkedHashSet;
24  import java.util.Set;
25  
26  import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer;
27  import org.apache.maven.model.Plugin;
28  import org.apache.maven.model.PluginExecution;
29  
30  /**
31   * @author Benjamin Bentmann
32   */
33  public class EmptyLifecyclePluginAnalyzer
34      implements LifeCyclePluginAnalyzer
35  {
36      public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
37      {
38          Set<Plugin> plugins;
39  
40          // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
41          if ( "JAR".equals( packaging ) )
42          {
43              plugins = new LinkedHashSet<Plugin>();
44  
45              plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
46              plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
47              plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
48              plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
49              plugins.add( newPlugin( "maven-install-plugin", "install" ) );
50              plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
51          }
52          else
53          {
54              plugins = Collections.emptySet();
55          }
56  
57          return plugins;
58      }
59  
60      private Plugin newPlugin( String artifactId, String... goals )
61      {
62          Plugin plugin = new Plugin();
63  
64          plugin.setGroupId( "org.apache.maven.plugins" );
65          plugin.setArtifactId( artifactId );
66  
67          for ( String goal : goals )
68          {
69              PluginExecution pluginExecution = new PluginExecution();
70              pluginExecution.setId( "default-" + goal );
71              pluginExecution.addGoal( goal );
72              plugin.addExecution( pluginExecution );
73          }
74  
75          return plugin;
76      }
77  
78  }