View Javadoc
1   package org.apache.maven.lifecycle;
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.model.Plugin;
27  import org.apache.maven.model.PluginExecution;
28  
29  /**
30   * @author Benjamin Bentmann
31   */
32  public class EmptyLifecyclePluginAnalyzer
33      implements LifeCyclePluginAnalyzer
34  {
35      public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
36      {
37          Set<Plugin> plugins;
38  
39          // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests
40          if ( "JAR".equals( packaging ) )
41          {
42              plugins = new LinkedHashSet<>();
43  
44              plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) );
45              plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) );
46              plugins.add( newPlugin( "maven-surefire-plugin", "test" ) );
47              plugins.add( newPlugin( "maven-jar-plugin", "jar" ) );
48              plugins.add( newPlugin( "maven-install-plugin", "install" ) );
49              plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) );
50          }
51          else
52          {
53              plugins = Collections.emptySet();
54          }
55  
56          return plugins;
57      }
58  
59      private Plugin newPlugin( String artifactId, String... goals )
60      {
61          Plugin plugin = new Plugin();
62  
63          plugin.setGroupId( "org.apache.maven.plugins" );
64          plugin.setArtifactId( artifactId );
65  
66          for ( String goal : goals )
67          {
68              PluginExecution pluginExecution = new PluginExecution();
69              pluginExecution.setId( "default-" + goal );
70              pluginExecution.addGoal( goal );
71              plugin.addExecution( pluginExecution );
72          }
73  
74          return plugin;
75      }
76  
77  }