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  
49      List<String> FIELD_LEVEL_ANNOTATIONS = Arrays.asList(
50              Parameter.class.getName(),
51              Component.class.getName(),
52              Deprecated.class.getName(),
53              V4_API_ANNOTATIONS_PACKAGE + ".Parameter",
54              V4_API_ANNOTATIONS_PACKAGE + ".Component");
55  
56      List<String> METHOD_LEVEL_ANNOTATIONS = Arrays.asList(
57              Parameter.class.getName(), Deprecated.class.getName(), V4_API_ANNOTATIONS_PACKAGE + ".Parameter");
58  
59      /**
60       * Scan classes for mojo annotations.
61       *
62       * @param request
63       * @return map of mojo-annotated classes keyed by full class name
64       * @throws ExtractionException
65       */
66      Map<String, MojoAnnotatedClass> scan(MojoAnnotationsScannerRequest request) throws ExtractionException;
67  }