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", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true )
45 public class SingleAssemblyMojo
46 extends AbstractAssemblyMojo
47 {
48 @Parameter( defaultValue = "${plugin}", readonly = true )
49 private PluginDescriptor plugin;
50
51 @Override
52 public void execute()
53 throws MojoExecutionException, MojoFailureException
54 {
55 verifyRemovedParameter( "classifier" );
56 verifyRemovedParameter( "descriptor" );
57 verifyRemovedParameter( "descriptorId" );
58 verifyRemovedParameter( "includeSite" );
59
60 super.execute();
61 }
62
63 private void verifyRemovedParameter( String paramName )
64 {
65 Object pluginConfiguration = plugin.getPlugin().getConfiguration();
66 if ( pluginConfiguration instanceof Xpp3Dom )
67 {
68 Xpp3Dom configDom = (Xpp3Dom) pluginConfiguration;
69
70 if ( configDom.getChild( paramName ) != null )
71 {
72 throw new IllegalArgumentException( "parameter '" + paramName
73 + "' has been removed from the plugin, please verify documentation." );
74 }
75 }
76 }
77
78
79
80 @Parameter( defaultValue = "${project}", readonly = true, required = true )
81 private MavenProject project;
82
83 @Override
84 public MavenProject getProject()
85 {
86 return project;
87 }
88 }