1 package org.apache.maven.plugins.assembly.mojos;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugin.MojoFailureException;
24 import org.apache.maven.plugin.descriptor.PluginDescriptor;
25
26 import org.apache.maven.plugins.annotations.Mojo;
27 import org.apache.maven.plugins.annotations.Parameter;
28 import org.apache.maven.plugins.annotations.ResolutionScope;
29 import org.apache.maven.project.MavenProject;
30 import org.codehaus.plexus.util.xml.Xpp3Dom;
31
32
33
34
35
36
37
38
39
40
41
42
43
44 @Mojo( name = "single", inheritByDefault = false, requiresDependencyResolution = ResolutionScope.TEST,
45 threadSafe = true )
46 public class SingleAssemblyMojo
47 extends AbstractAssemblyMojo
48 {
49 @Parameter( defaultValue = "${plugin}", readonly = true )
50 private PluginDescriptor plugin;
51
52 @Override
53 public void execute()
54 throws MojoExecutionException, MojoFailureException
55 {
56 verifyRemovedParameter( "classifier" );
57 verifyRemovedParameter( "descriptor" );
58 verifyRemovedParameter( "descriptorId" );
59 verifyRemovedParameter( "includeSite" );
60
61 super.execute();
62 }
63
64 private void verifyRemovedParameter( String paramName )
65 {
66 Object pluginConfiguration = plugin.getPlugin().getConfiguration();
67 if ( pluginConfiguration instanceof Xpp3Dom )
68 {
69 Xpp3Dom configDom = (Xpp3Dom) pluginConfiguration;
70
71 if ( configDom.getChild( paramName ) != null )
72 {
73 throw new IllegalArgumentException( "parameter '" + paramName
74 + "' has been removed from the plugin, please verify documentation." );
75 }
76 }
77 }
78
79
80
81 @Parameter( defaultValue = "${project}", readonly = true, required = true )
82 private MavenProject project;
83
84 @Override
85 public MavenProject getProject()
86 {
87 return project;
88 }
89 }