1 package org.apache.maven.project;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
32
33 public class EmptyLifecyclePluginAnalyzer
34 implements LifeCyclePluginAnalyzer
35 {
36 public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging )
37 {
38 Set<Plugin> plugins;
39
40
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 }