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> Phase is after the "compilation" of any scripts.
32 *
33 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
34 * @version $Id: DescriptorGeneratorMojo.java 940010 2010-05-01 13:35:33Z bentmann $
35 * @since 2.0
36 * @goal descriptor
37 * @phase generate-resources
38 * @requiresDependencyResolution runtime
39 */
40 public class DescriptorGeneratorMojo
41 extends AbstractGeneratorMojo
42 {
43 /**
44 * The directory where the generated <code>plugin.xml</code> file will be put.
45 *
46 * @parameter default-value="${project.build.outputDirectory}/META-INF/maven"
47 */
48 protected File outputDirectory;
49
50 /**
51 * A flag to disable generation of the <code>plugin.xml</code> in favor of a hand authored plugin descriptor.
52 *
53 * @parameter default-value="false"
54 * @since 2.6
55 */
56 private boolean skipDescriptor;
57
58 /** {@inheritDoc} */
59 protected File getOutputDirectory()
60 {
61 return outputDirectory;
62 }
63
64 /** {@inheritDoc} */
65 protected Generator createGenerator()
66 {
67 return new PluginDescriptorGenerator();
68 }
69
70 /** {@inheritDoc} */
71 public void execute()
72 throws MojoExecutionException
73 {
74 if ( skipDescriptor )
75 {
76 return;
77 }
78
79 super.execute();
80 }
81
82 }