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>@goal</tt> tag is used to reference the goal name of the Mojo and has annotation parameter. 030 * <br/> 031 * The following is a sample declaration: 032 * <pre> 033 * /** 034 *  * Dummy Mojo. 035 *  * 036 *  * @goal <goalName> 037 *  * ... 038 *  */ 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.MojoGoalTypeTaglet' 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 'goal:t:Is defined by the goal name:' 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: MojoGoalTypeTaglet.html 1030109 2018-05-20 14:45:18Z hboutemy $ 054 */ 055public class MojoGoalTypeTaglet 056 extends AbstractMojoTypeTaglet 057{ 058 /** The Javadoc annotation */ 059 private static final String NAME = JavadocMojoAnnotation.GOAL; 060 061 /** The Javadoc text which will be added to the generated page. */ 062 protected static final String HEADER = "Is defined by the goal name"; 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>@goal</code> has a 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>@goal</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 MojoGoalTypeTaglet#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 MojoGoalTypeTaglet tag = new MojoGoalTypeTaglet(); 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}