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.Repeatable;
24 import java.lang.annotation.Retention;
25 import java.lang.annotation.RetentionPolicy;
26 import java.lang.annotation.Target;
27
28 /**
29 * Specifies a parameter value for a Mojo in a Maven plugin test.
30 * This annotation can be used to configure individual Mojo parameters
31 * without requiring a full POM file.
32 *
33 * <p>The annotation is repeatable, allowing multiple parameters to be set
34 * on a single test method or parameter. For multiple parameters, you can
35 * either use multiple {@code @MojoParameter} annotations or a single
36 * {@link MojoParameters} annotation.</p>
37 *
38 * <p>Example usage with a single parameter:</p>
39 * <pre>
40 * {@code
41 * @Test
42 * @InjectMojo(goal = "compile")
43 * @MojoParameter(name = "source", value = "1.8")
44 * void testCompilation(CompileMojo mojo) {
45 * mojo.execute();
46 * }
47 * }
48 * </pre>
49 *
50 * <p>Example usage with multiple parameters:</p>
51 * <pre>
52 * {@code
53 * @Test
54 * @InjectMojo(goal = "compile")
55 * @MojoParameter(name = "source", value = "1.8")
56 * @MojoParameter(name = "target", value = "1.8")
57 * @MojoParameter(name = "debug", value = "true")
58 * void testCompilation(CompileMojo mojo) {
59 * mojo.execute();
60 * }
61 * }
62 * </pre>
63 *
64 * @see MojoParameters
65 * @see InjectMojo
66 * @see MojoTest
67 * @since 3.4.0
68 */
69 @Retention(RetentionPolicy.RUNTIME)
70 @Repeatable(MojoParameters.class)
71 @Inherited
72 @Target(ElementType.METHOD)
73 public @interface MojoParameter {
74 String name();
75
76 String value();
77 }