001package org.apache.maven.tools.plugin.javadoc;
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
022import java.util.Map;
023
024import org.apache.maven.tools.plugin.extractor.javadoc.JavadocMojoAnnotation;
025
026import com.sun.tools.doclets.Taglet;
027
028/**
029 * The <tt>@execute</tt> tag is used to reference the invocation way of the Mojo and has parameters.
030 * <br/>
031 * The following is a sample declaration:
032 * <pre>
033 * &#x2f;&#x2a;&#x2a;
034 * &#x20;&#x2a; Dummy Mojo.
035 * &#x20;&#x2a;
036 * &#x20;&#x2a; &#64;execute phase="..." lifecycle="..."
037 * &#x20;&#x2a; &lt;OR&gt;
038 * &#x20;&#x2a; &#64;execute phase="..."
039 * &#x20;&#x2a; &lt;OR&gt;
040 * &#x20;&#x2a; &#64;execute goal="..."
041 * &#x20;&#x2a; ...
042 * &#x20;&#x2a;&#x2f;
043 * public class MyMojo extends AbstractMojo{}
044 * </pre>
045 * To use it, calling the <code>Javadoc</code> tool with the following:
046 * <pre>
047 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoExecuteTypeTaglet'
048 * </pre>
049 *
050 * @see <a href="package-summary.html#package_description">package-summary.html</a>
051 *
052 * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
053 * @version $Id: MojoExecuteTypeTaglet.html 1024032 2018-01-19 18:16:30Z hboutemy $
054 */
055public class MojoExecuteTypeTaglet
056    extends AbstractMojoTypeTaglet
057{
058    /** The Javadoc annotation */
059    private static final String NAME = JavadocMojoAnnotation.EXECUTE;
060
061    private static final String[] PARAMETERS_NAME = {
062        JavadocMojoAnnotation.EXECUTE_PHASE,
063        JavadocMojoAnnotation.EXECUTE_LIFECYCLE,
064        JavadocMojoAnnotation.EXECUTE_GOAL };
065
066    /** The Javadoc text which will be added to the generated page. */
067    protected static final String HEADER = "Is defined to be executed in";
068
069    /**
070     * @return By default, return the string defined in {@linkplain #HEADER}.
071     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
072     * @see #HEADER
073     */
074    public String getHeader()
075    {
076        return HEADER;
077    }
078
079    /**
080     * @return <code>null</code> since <code>@execute</code> has no value.
081     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
082     */
083    public String getAllowedValue()
084    {
085        return null;
086    }
087
088    /**
089     * @return <code>MojoExecuteTypeTaglet#PARAMETERS_NAME</code> since <code>@execute</code> has parameters.
090     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
091     * @see #PARAMETERS_NAME
092     */
093    public String[] getAllowedParameterNames()
094    {
095        return PARAMETERS_NAME;
096    }
097
098    /**
099     * @return By default, return the name of this taglet.
100     * @see com.sun.tools.doclets.Taglet#getName()
101     * @see MojoExecuteTypeTaglet#NAME
102     */
103    public String getName()
104    {
105        return NAME;
106    }
107
108    /**
109     * Register this Taglet.
110     *
111     * @param tagletMap the map to register this tag to.
112     */
113    public static void register( Map<String, Taglet> tagletMap )
114    {
115        MojoExecuteTypeTaglet tag = new MojoExecuteTypeTaglet();
116        Taglet t = tagletMap.get( tag.getName() );
117        if ( t != null )
118        {
119            tagletMap.remove( tag.getName() );
120        }
121        tagletMap.put( tag.getName(), tag );
122    }
123}