View Javadoc
1   package org.apache.maven.plugins.assembly.mojos;
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 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   * Assemble an application bundle or distribution from an assembly descriptor. This goal is suitable either for binding
34   * to the lifecycle or calling directly from the command line (provided all required files are available before the
35   * build starts, or are produced by another goal specified before this one on the command line).
36   * <br >
37   * Note that the parameters {@code descriptors}, {@code descriptorRefs}, and {@code descriptorSourceDirectory}
38   * are disjoint, i.e., they are not combined during descriptor location calculation.
39   *
40   * @author <a href="mailto:jdcasey@apache.org">John Casey</a>
41   * @author <a href="mailto:brett@apache.org">Brett Porter</a>
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  }