1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.maven.plugins.assembly.mojos;
20
21 import org.apache.maven.plugin.MojoExecutionException;
22 import org.apache.maven.plugin.MojoFailureException;
23 import org.apache.maven.plugin.descriptor.PluginDescriptor;
24 import org.apache.maven.plugins.annotations.Mojo;
25 import org.apache.maven.plugins.annotations.Parameter;
26 import org.apache.maven.plugins.annotations.ResolutionScope;
27 import org.apache.maven.project.MavenProject;
28 import org.codehaus.plexus.util.xml.Xpp3Dom;
29
30 /**
31 * Assemble an application bundle or distribution from an assembly descriptor. This goal is suitable either for binding
32 * to the lifecycle or calling directly from the command line (provided all required files are available before the
33 * build starts, or are produced by another goal specified before this one on the command line).
34 * <br >
35 * Note that the parameters {@code descriptors}, {@code descriptorRefs}, and {@code descriptorSourceDirectory}
36 * are disjoint, i.e., they are not combined during descriptor location calculation.
37 *
38 * @author <a href="mailto:jdcasey@apache.org">John Casey</a>
39 * @author <a href="mailto:brett@apache.org">Brett Porter</a>
40 *
41 */
42 @Mojo(name = "single", requiresDependencyResolution = ResolutionScope.TEST, threadSafe = true)
43 public class SingleAssemblyMojo extends AbstractAssemblyMojo {
44 @Parameter(defaultValue = "${plugin}", readonly = true)
45 private PluginDescriptor plugin;
46
47 @Override
48 public void execute() throws MojoExecutionException, MojoFailureException {
49 verifyRemovedParameter("classifier");
50 verifyRemovedParameter("descriptor");
51 verifyRemovedParameter("descriptorId");
52 verifyRemovedParameter("includeSite");
53
54 super.execute();
55 }
56
57 private void verifyRemovedParameter(String paramName) {
58 Object pluginConfiguration = plugin.getPlugin().getConfiguration();
59 if (pluginConfiguration instanceof Xpp3Dom) {
60 Xpp3Dom configDom = (Xpp3Dom) pluginConfiguration;
61
62 if (configDom.getChild(paramName) != null) {
63 throw new IllegalArgumentException(
64 "parameter '" + paramName + "' has been removed from the plugin, please verify documentation.");
65 }
66 }
67 }
68
69 /**
70 */
71 @Parameter(defaultValue = "${project}", readonly = true, required = true)
72 private MavenProject project;
73
74 @Override
75 public MavenProject getProject() {
76 return project;
77 }
78 }