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 com.sun.tools.doclets.Taglet; 023 024import org.apache.maven.tools.plugin.extractor.javadoc.JavadocMojoAnnotation; 025 026import java.util.Map; 027 028//CHECKSTYLE_OFF: LineLength 029/** 030 * The <tt>@requiresDependencyCollection</tt> tag is used to specify the required dependencies in the specified scope 031 * and has parameter. 032 * <br/> 033 * The following is a sample declaration: 034 * <pre> 035 * /** 036 *  * Dummy Mojo. 037 *  * 038 *  * @requiresDependencyCollection <requiredScope> 039 *  * ... 040 *  */ 041 * public class MyMojo extends AbstractMojo{} 042 * </pre> 043 * To use it, calling the <code>Javadoc</code> tool with the following: 044 * <pre> 045 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyCollectionTypeTaglet' 046 * </pre> 047 * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following: 048 * <pre> 049 * javadoc ... -tag 'requiresDependencyCollection:t:Requires the collection of the dependencies in this specified scope:' 050 * </pre> 051 * 052 * @see <a href="package-summary.html#package_description">package-summary.html</a> 053 * 054 * @author Kristian Rosenvold 055 * @version $Id: MojoRequiresDependencyCollectionTypeTaglet.html 1030109 2018-05-20 14:45:18Z hboutemy $ 056 */ 057//CHECKSTYLE_ON: LineLength 058public class MojoRequiresDependencyCollectionTypeTaglet 059 extends AbstractMojoTypeTaglet 060{ 061 /** The Javadoc annotation */ 062 private static final String NAME = JavadocMojoAnnotation.REQUIRES_DEPENDENCY_COLLECTION; 063 064 /** The Javadoc text which will be added to the generated page. */ 065 protected static final String HEADER = "Collects the dependencies in this specified scope"; 066 067 /** 068 * @return By default, return the string defined in {@linkplain #HEADER}. 069 * @see AbstractMojoTaglet#getHeader() 070 * @see #HEADER 071 */ 072 public String getHeader() 073 { 074 return HEADER; 075 } 076 077 /** 078 * @return <code>"*"</code> since <code>@requiresDependencyCollection</code> has value. 079 * @see AbstractMojoTaglet#getAllowedValue() 080 */ 081 public String getAllowedValue() 082 { 083 return "*"; 084 } 085 086 /** 087 * @return <code>null</code> since <code>@requiresDependencyCollection</code> has no parameter. 088 * @see AbstractMojoTaglet#getAllowedParameterNames() 089 */ 090 public String[] getAllowedParameterNames() 091 { 092 return null; 093 } 094 095 /** 096 * @return By default, return the name of this taglet. 097 * @see com.sun.tools.doclets.Taglet#getName() 098 * @see org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyCollectionTypeTaglet#NAME 099 */ 100 public String getName() 101 { 102 return NAME; 103 } 104 105 /** 106 * Register this Taglet. 107 * 108 * @param tagletMap the map to register this tag to. 109 */ 110 public static void register( Map<String, Taglet> tagletMap ) 111 { 112 MojoRequiresDependencyCollectionTypeTaglet tag = new MojoRequiresDependencyCollectionTypeTaglet(); 113 Taglet t = tagletMap.get( tag.getName() ); 114 if ( t != null ) 115 { 116 tagletMap.remove( tag.getName() ); 117 } 118 tagletMap.put( tag.getName(), tag ); 119 } 120}