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.api.plugin.annotations;
20  
21  import java.lang.annotation.Documented;
22  import java.lang.annotation.ElementType;
23  import java.lang.annotation.Inherited;
24  import java.lang.annotation.Retention;
25  import java.lang.annotation.RetentionPolicy;
26  import java.lang.annotation.Target;
27  
28  import org.apache.maven.api.annotations.Experimental;
29  import org.apache.maven.api.annotations.Nonnull;
30  
31  /**
32   * This annotation will mark your class as a Mojo, which is the implementation of a goal in a Maven plugin.
33   * <p>
34   * The mojo can be annotated with {@code org.apache.maven.api.di.*} annotations to
35   * control the lifecycle of the mojo itself, and to inject other beans.
36   * </p>
37   * <p>
38   * The mojo class can also be injected with an {@link Execute} annotation to specify a
39   * forked lifecycle.
40   * </p>
41   * <p>
42   * The {@link Parameter} annotation can be added on fields to inject data
43   * from the plugin configuration or from other components.
44   * </p>
45   * <p>
46   * Fields can also be annotated with the {@link Resolution} annotation to be injected
47   * with the dependency collection or resolution result for the project.
48   * </p>
49   *
50   * @since 4.0.0
51   */
52  @Experimental
53  @Documented
54  @Retention(RetentionPolicy.RUNTIME)
55  @Target(ElementType.TYPE)
56  @Inherited
57  public @interface Mojo {
58      /**
59       * goal name (required).
60       * @return the goal name
61       */
62      @Nonnull
63      String name();
64  
65      /**
66       * default phase to bind your mojo.
67       * @return the default phase
68       */
69      @Nonnull
70      String defaultPhase() default "";
71  
72      /**
73       * does your mojo requires a project to be executed?
74       * @return requires a project
75       */
76      boolean projectRequired() default true;
77  
78      /**
79       * if the Mojo uses the Maven project and its subprojects.
80       * @return uses the Maven project and its subprojects
81       */
82      boolean aggregator() default false;
83  
84      /**
85       * does this Mojo need to be online to be executed?
86       * @return need to be online
87       */
88      boolean onlineRequired() default false;
89  
90      /**
91       * TODO: v4: add a SPI for the configurator
92       * configurator bean name.
93       * @return the configurator bean name
94       */
95      @Nonnull
96      String configurator() default "";
97  
98      /**
99       * Indicates whether dependency collection will be
100      * required when executing the Mojo.
101      * If not set, it will be inferred from the fields
102      * annotated with the {@link Resolution} annotation.
103      */
104     @Nonnull
105     boolean dependencyCollection() default false;
106 
107     /**
108      * Comma separated list of path scopes that will be
109      * required for dependency resolution.
110      * If not set, it will be inferred from the fields
111      * annotated with the {@link Resolution} annotation.
112      */
113     @Nonnull
114     String dependencyResolutionPathScopes() default "";
115 }