View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.tools.plugin.extractor.annotations.scanner;
20  
21  import java.util.Arrays;
22  import java.util.List;
23  import java.util.Map;
24  
25  import org.apache.maven.plugins.annotations.Component;
26  import org.apache.maven.plugins.annotations.Execute;
27  import org.apache.maven.plugins.annotations.Mojo;
28  import org.apache.maven.plugins.annotations.Parameter;
29  import org.apache.maven.tools.plugin.extractor.ExtractionException;
30  
31  /**
32   * @author Olivier Lamy
33   * @since 3.0
34   */
35  public interface MojoAnnotationsScanner {
36      String ROLE = MojoAnnotationsScanner.class.getName();
37  
38      String V4_API_PLUGIN_PACKAGE = "org.apache.maven.api.plugin";
39  
40      String V4_API_ANNOTATIONS_PACKAGE = V4_API_PLUGIN_PACKAGE + ".annotations";
41  
42      List<String> CLASS_LEVEL_ANNOTATIONS = Arrays.asList(
43              Mojo.class.getName(),
44              Execute.class.getName(),
45              Deprecated.class.getName(),
46              V4_API_ANNOTATIONS_PACKAGE + ".Mojo",
47              V4_API_ANNOTATIONS_PACKAGE + ".Execute",
48              V4_API_ANNOTATIONS_PACKAGE + ".After",
49              V4_API_ANNOTATIONS_PACKAGE + ".Afters");
50  
51      List<String> FIELD_LEVEL_ANNOTATIONS = Arrays.asList(
52              Parameter.class.getName(),
53              Component.class.getName(),
54              Deprecated.class.getName(),
55              V4_API_ANNOTATIONS_PACKAGE + ".Parameter",
56              V4_API_ANNOTATIONS_PACKAGE + ".Resolution");
57  
58      List<String> METHOD_LEVEL_ANNOTATIONS = Arrays.asList(
59              Parameter.class.getName(), Deprecated.class.getName(), V4_API_ANNOTATIONS_PACKAGE + ".Parameter");
60  
61      /**
62       * Scan classes for mojo annotations.
63       *
64       * @param request
65       * @return map of mojo-annotated classes keyed by full class name
66       * @throws ExtractionException
67       */
68      Map<String, MojoAnnotatedClass> scan(MojoAnnotationsScannerRequest request) throws ExtractionException;
69  }