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>@phase</tt> tag is used to reference the binded phase name of the Mojo and has has parameter.
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;phase &lt;phaseName&gt;
037 * &#x20;&#x2a; ...
038 * &#x20;&#x2a;&#x2f;
039 * public class MyMojo extends AbstractMojo{}
040 * </pre>
041 * To use it, calling the <code>Javadoc</code> tool with the following:
042 * <pre>
043 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoPhaseTypeTaglet'
044 * </pre>
045 * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following:
046 * <pre>
047 * javadoc ... -tag 'phase:t:Is bound to the specified phase of the standard build lifecycle:'
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: MojoPhaseTypeTaglet.html 1030109 2018-05-20 14:45:18Z hboutemy $
054 */
055public class MojoPhaseTypeTaglet
056    extends AbstractMojoTypeTaglet
057{
058    /** The Javadoc annotation */
059    private static final String NAME = JavadocMojoAnnotation.PHASE;
060
061    /** The Javadoc text which will be added to the generated page. */
062    protected static final String HEADER = "Is bound to the specified phase of the standard build lifecycle";
063
064    /**
065     * @return By default, return the string defined in {@linkplain #HEADER}.
066     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getHeader()
067     * @see #HEADER
068     */
069    public String getHeader()
070    {
071        return HEADER;
072    }
073
074    /**
075     * @return <code>"*"</code> since <code>@phase</code> has value.
076     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedValue()
077     */
078    public String getAllowedValue()
079    {
080        return "*";
081    }
082
083    /**
084     * @return <code>null</code> since <code>@phase</code> has no parameter.
085     * @see org.apache.maven.tools.plugin.javadoc.AbstractMojoTaglet#getAllowedParameterNames()
086     */
087    public String[] getAllowedParameterNames()
088    {
089        return null;
090    }
091
092    /**
093     * @return By default, return the name of this taglet.
094     * @see com.sun.tools.doclets.Taglet#getName()
095     * @see MojoPhaseTypeTaglet#NAME
096     */
097    public String getName()
098    {
099        return NAME;
100    }
101
102    /**
103     * Register this Taglet.
104     *
105     * @param tagletMap the map to register this tag to.
106     */
107    public static void register( Map<String, Taglet> tagletMap )
108    {
109        MojoPhaseTypeTaglet tag = new MojoPhaseTypeTaglet();
110        Taglet t = tagletMap.get( tag.getName() );
111        if ( t != null )
112        {
113            tagletMap.remove( tag.getName() );
114        }
115        tagletMap.put( tag.getName(), tag );
116    }
117}