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.testing;
20  
21  import java.lang.annotation.ElementType;
22  import java.lang.annotation.Inherited;
23  import java.lang.annotation.Retention;
24  import java.lang.annotation.RetentionPolicy;
25  import java.lang.annotation.Target;
26  
27  /**
28   * Annotation used in Maven plugin tests to inject and configure a Mojo instance.
29   * This annotation can be applied to either test methods or parameters to specify
30   * which Mojo should be instantiated and how it should be configured.
31   *
32   * <p>The annotation requires a {@code goal} attribute to specify which Mojo goal
33   * should be instantiated. Optionally, a custom {@code pom} file can be specified
34   * to provide specific configuration for the test.</p>
35   *
36   * <p>Example usage on a test method:</p>
37   * <pre>
38   * {@code
39   * @Test
40   * @InjectMojo(goal = "compile")
41   * void testCompileMojo(CompileMojo mojo) {
42   *     mojo.execute();
43   *     // verify compilation results
44   * }
45   * }
46   * </pre>
47   *
48   * <p>Example usage with a custom POM:</p>
49   * <pre>
50   * {@code
51   * @Test
52   * @InjectMojo(
53   *     goal = "compile",
54   *     pom = "src/test/resources/test-pom.xml"
55   * )
56   * void testCompileMojoWithCustomConfig(CompileMojo mojo) {
57   *     mojo.execute();
58   *     // verify compilation results
59   * }
60   * }
61   * </pre>
62   *
63   * <p>The annotation can be used in conjunction with {@link MojoParameter} to provide
64   * specific parameter values for the Mojo:</p>
65   * <pre>
66   * {@code
67   * @Test
68   * @InjectMojo(goal = "compile")
69   * @MojoParameter(name = "source", value = "1.8")
70   * @MojoParameter(name = "target", value = "1.8")
71   * void testCompileMojoWithParameters(CompileMojo mojo) {
72   *     mojo.execute();
73   *     // verify compilation results
74   * }
75   * }
76   * </pre>
77   *
78   * @see MojoTest
79   * @see MojoParameter
80   * @see MojoExtension
81   * @since 3.4.0
82   */
83  @Retention(RetentionPolicy.RUNTIME)
84  @Inherited
85  @Target(ElementType.METHOD)
86  public @interface InjectMojo {
87  
88      String goal();
89  
90      String pom() default "";
91  }