1 package org.apache.maven.tools.plugin.javadoc;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import com.sun.tools.doclets.Taglet;
23
24 import org.apache.maven.tools.plugin.extractor.javadoc.JavadocMojoAnnotation;
25
26 import java.util.Map;
27
28 //CHECKSTYLE_OFF: LineLength
29 /**
30 * The <tt>@requiresDependencyCollection</tt> tag is used to specify the required dependencies in the specified scope
31 * and has parameter.
32 * <br/>
33 * The following is a sample declaration:
34 * <pre>
35 * /**
36 *  * Dummy Mojo.
37 *  *
38 *  * @requiresDependencyCollection <requiredScope>
39 *  * ...
40 *  */
41 * public class MyMojo extends AbstractMojo{}
42 * </pre>
43 * To use it, calling the <code>Javadoc</code> tool with the following:
44 * <pre>
45 * javadoc ... -taglet 'org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyCollectionTypeTaglet'
46 * </pre>
47 * <b>Note</b>: This taglet is similar to call the <code>Javadoc</code> tool with the following:
48 * <pre>
49 * javadoc ... -tag 'requiresDependencyCollection:t:Requires the collection of the dependencies in this specified scope:'
50 * </pre>
51 *
52 * @see <a href="package-summary.html#package_description">package-summary.html</a>
53 *
54 * @author Kristian Rosenvold
55 * @version $Id: MojoRequiresDependencyCollectionTypeTaglet.html 1024032 2018-01-19 18:16:30Z hboutemy $
56 */
57 //CHECKSTYLE_ON: LineLength
58 public class MojoRequiresDependencyCollectionTypeTaglet
59 extends AbstractMojoTypeTaglet
60 {
61 /** The Javadoc annotation */
62 private static final String NAME = JavadocMojoAnnotation.REQUIRES_DEPENDENCY_COLLECTION;
63
64 /** The Javadoc text which will be added to the generated page. */
65 protected static final String HEADER = "Collects the dependencies in this specified scope";
66
67 /**
68 * @return By default, return the string defined in {@linkplain #HEADER}.
69 * @see AbstractMojoTaglet#getHeader()
70 * @see #HEADER
71 */
72 public String getHeader()
73 {
74 return HEADER;
75 }
76
77 /**
78 * @return <code>"*"</code> since <code>@requiresDependencyCollection</code> has value.
79 * @see AbstractMojoTaglet#getAllowedValue()
80 */
81 public String getAllowedValue()
82 {
83 return "*";
84 }
85
86 /**
87 * @return <code>null</code> since <code>@requiresDependencyCollection</code> has no parameter.
88 * @see AbstractMojoTaglet#getAllowedParameterNames()
89 */
90 public String[] getAllowedParameterNames()
91 {
92 return null;
93 }
94
95 /**
96 * @return By default, return the name of this taglet.
97 * @see com.sun.tools.doclets.Taglet#getName()
98 * @see org.apache.maven.tools.plugin.javadoc.MojoRequiresDependencyCollectionTypeTaglet#NAME
99 */
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 }