001 package org.apache.maven.plugin.plugin; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import org.apache.maven.plugin.MojoExecutionException; 023 import org.apache.maven.tools.plugin.generator.Generator; 024 import org.apache.maven.tools.plugin.generator.PluginDescriptorGenerator; 025 026 import java.io.File; 027 028 /** 029 * Generate a plugin descriptor. 030 * <br/> 031 * <b>Note:</b> Since 3.0, <a href="http://maven.apache.org/ref/current/maven-core/lifecycles.html">phase</a> 032 * is after the "compilation" of any scripts. 033 * 034 * @author <a href="mailto:jason@maven.org">Jason van Zyl</a> 035 * @version $Id: DescriptorGeneratorMojo.java 1337808 2012-05-13 08:29:05Z hboutemy $ 036 * @since 2.0 037 * @goal descriptor 038 * @phase process-classes 039 * @requiresDependencyResolution runtime 040 */ 041 public class DescriptorGeneratorMojo 042 extends AbstractGeneratorMojo 043 { 044 /** 045 * The directory where the generated <code>plugin.xml</code> file will be put. 046 * 047 * @parameter default-value="${project.build.outputDirectory}/META-INF/maven" 048 */ 049 protected File outputDirectory; 050 051 /** 052 * A flag to disable generation of the <code>plugin.xml</code> in favor of a hand authored plugin descriptor. 053 * 054 * @parameter default-value="false" 055 * @since 2.6 056 */ 057 private boolean skipDescriptor; 058 059 /** {@inheritDoc} */ 060 protected File getOutputDirectory() 061 { 062 return outputDirectory; 063 } 064 065 /** {@inheritDoc} */ 066 protected Generator createGenerator() 067 { 068 return new PluginDescriptorGenerator(); 069 } 070 071 /** {@inheritDoc} */ 072 public void execute() 073 throws MojoExecutionException 074 { 075 if ( skipDescriptor ) 076 { 077 return; 078 } 079 080 super.execute(); 081 } 082 083 }