You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maven annotation processor and plugin recipes should correctly handle parent and aggregator poms (#6546)
* add test to secure assumptions and document planned behavior of `AddAnnotationProcessor`
* Refactor AddAnnotationProcessor tests for single vs multi-module behavior
Restructure tests into @nested classes to clearly define expected behavior:
- SingleModuleProject: add to build/plugins
- MultiModuleProject: add to build/pluginManagement/plugins in root pom only
Remove redundant tests, keeping @DocumentExample and version handling tests.
* Add recipe to add a managed plugin by reusing the add plugin visitor
* Expand MavenPlugin trait to be limitable to managed or build plugins
* use AddPlugin, AddManagedPlugin and limitable MavenPlugin trait to add annotation processors where expected
* advance `MavenPlugin` trait to also be limitable on groupd and artifact id
* add comments and advance tests
* update recipes.csv
* enhance `AddAnnotationProcessortTest` to reflect handling of separated aggregator and parent poms
* update recipe to deal with individual reactor and parent poms
* update recipes.csv
* Licensed under the Apache License, Version 2.0 (the "License");
5
+
* you may not use this file except in compliance with the License.
6
+
* You may obtain a copy of the License at
7
+
* <p>
8
+
* https://www.apache.org/licenses/LICENSE-2.0
9
+
* <p>
10
+
* Unless required by applicable law or agreed to in writing, software
11
+
* distributed under the License is distributed on an "AS IS" BASIS,
12
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+
* See the License for the specific language governing permissions and
14
+
* limitations under the License.
15
+
*/
16
+
packageorg.openrewrite.maven;
17
+
18
+
importlombok.EqualsAndHashCode;
19
+
importlombok.Value;
20
+
importorg.intellij.lang.annotations.Language;
21
+
importorg.jspecify.annotations.Nullable;
22
+
importorg.openrewrite.ExecutionContext;
23
+
importorg.openrewrite.Option;
24
+
importorg.openrewrite.Recipe;
25
+
importorg.openrewrite.TreeVisitor;
26
+
importorg.openrewrite.xml.XPathMatcher;
27
+
28
+
@Value
29
+
@EqualsAndHashCode(callSuper = false)
30
+
publicclassAddManagedPluginextendsRecipe {
31
+
@Option(displayName = "Group",
32
+
description = "The first part of a dependency coordinate 'org.openrewrite.maven:rewrite-maven-plugin:VERSION'.",
33
+
example = "org.openrewrite.maven")
34
+
StringgroupId;
35
+
36
+
@Option(displayName = "Artifact",
37
+
description = "The second part of a dependency coordinate 'org.openrewrite.maven:rewrite-maven-plugin:VERSION'.",
38
+
example = "rewrite-maven-plugin")
39
+
StringartifactId;
40
+
41
+
@Option(displayName = "Version",
42
+
description = "A fixed version of the plugin to add.",
43
+
example = "1.0.0",
44
+
required = false)
45
+
@Nullable
46
+
Stringversion;
47
+
48
+
@Language("xml")
49
+
@Option(displayName = "Configuration",
50
+
description = "Optional plugin configuration provided as raw XML",
51
+
example = "<configuration><foo>foo</foo></configuration>",
52
+
required = false)
53
+
@Nullable
54
+
Stringconfiguration;
55
+
56
+
@Language("xml")
57
+
@Option(displayName = "Dependencies",
58
+
description = "Optional plugin dependencies provided as raw XML.",
59
+
example = "<dependencies><dependency><groupId>com.yourorg</groupId><artifactId>core-lib</artifactId><version>1.0.0</version></dependency></dependencies>",
60
+
required = false)
61
+
@Nullable
62
+
Stringdependencies;
63
+
64
+
@Language("xml")
65
+
@Option(displayName = "Executions",
66
+
description = "Optional executions provided as raw XML.",
67
+
example = "<executions><execution><phase>generate-sources</phase><goals><goal>add-source</goal></goals></execution></executions>",
68
+
required = false)
69
+
@Nullable
70
+
Stringexecutions;
71
+
72
+
@Option(displayName = "File pattern",
73
+
description = "A glob expression that can be used to constrain which directories or source files should be searched. " +
74
+
"Multiple patterns may be specified, separated by a semicolon `;`. " +
75
+
"If multiple patterns are supplied any of the patterns matching will be interpreted as a match. " +
0 commit comments