View Javadoc

1   package org.apache.maven.plugin.plugin;
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.tools.plugin.generator.Generator;
24  import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator;
25  
26  import java.io.File;
27  
28  /**
29   * Generate a plugin descriptor.
30   * <br/>
31   * <b>Note:</b> Since 3.0, <a href="http://maven.apache.org/ref/current/maven-core/lifecycles.html">phase</a>
32   * is after the "compilation" of any scripts.
33   *
34   * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
35   * @version $Id: DescriptorGeneratorMojo.java 1337808 2012-05-13 08:29:05Z hboutemy $
36   * @since 2.0
37   * @goal descriptor
38   * @phase process-classes
39   * @requiresDependencyResolution runtime
40   */
41  public class DescriptorGeneratorMojo
42      extends AbstractGeneratorMojo
43  {
44      /**
45       * The directory where the generated <code>plugin.xml</code> file will be put.
46       *
47       * @parameter default-value="${project.build.outputDirectory}/META-INF/maven"
48       */
49      protected File outputDirectory;
50  
51      /**
52       * A flag to disable generation of the <code>plugin.xml</code> in favor of a hand authored plugin descriptor.
53       * 
54       * @parameter default-value="false"
55       * @since 2.6
56       */
57      private boolean skipDescriptor;
58  
59      /** {@inheritDoc} */
60      protected File getOutputDirectory()
61      {
62          return outputDirectory;
63      }
64  
65      /** {@inheritDoc} */
66      protected Generator createGenerator()
67      {
68          return new PluginDescriptorGenerator();
69      }
70  
71      /** {@inheritDoc} */
72      public void execute()
73          throws MojoExecutionException
74      {
75          if ( skipDescriptor )
76          {
77              return;
78          }
79  
80          super.execute();
81      }
82  
83  }