Skip to content

Commit 932b979

Browse files
BhavanaPidapabhavanapidapa
andauthored
Moved this recipe and test from rewrite liberty (#766)
Co-authored-by: bhavanapidapa <bhavana.pidapa1@ibm.com>
1 parent b0b496a commit 932b979

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed

src/main/resources/META-INF/rewrite/ibm-java.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,14 @@ recipeList:
159159
groupId: javax.activation
160160
artifactId: activation
161161
newConfiguration: compileOnly
162+
---
163+
type: specs.openrewrite.org/v1beta/recipe
164+
name: org.openrewrite.java.migrate.WasDevMvnChangeParentArtifactId
165+
displayName: Change `net.wasdev.maven.parent:java8-parent` to `:parent`
166+
description: This recipe changes the artifactId of the `<parent>` tag in the `pom.xml` from `java8-parent` to `parent`.
167+
recipeList:
168+
- org.openrewrite.maven.ChangeParentPom:
169+
oldGroupId: net.wasdev.maven.parent
170+
oldArtifactId: java8-parent
171+
newArtifactId: parent
172+
newVersion: 1.4
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright 2025 the original author or authors.
3+
* <p>
4+
* 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+
package org.openrewrite.java.migrate;
17+
18+
import org.junit.jupiter.api.Test;
19+
import org.openrewrite.DocumentExample;
20+
import org.openrewrite.test.RewriteTest;
21+
22+
import static org.openrewrite.maven.Assertions.pomXml;
23+
24+
class WasDevMvnChangeParentArtifactIdTest implements RewriteTest {
25+
26+
@DocumentExample
27+
@Test
28+
void mvnChangeParentArtifactId() {
29+
rewriteRun(
30+
spec -> spec.recipeFromResources("org.openrewrite.java.migrate.WasDevMvnChangeParentArtifactId"),
31+
//language=XML
32+
pomXml(
33+
"""
34+
<project>
35+
<modelVersion>4.0.0</modelVersion>
36+
<parent>
37+
<groupId>net.wasdev.maven.parent</groupId>
38+
<artifactId>java8-parent</artifactId>
39+
<version>1.4</version>
40+
</parent>
41+
<artifactId>my-artifact</artifactId>
42+
</project>
43+
""",
44+
"""
45+
<project>
46+
<modelVersion>4.0.0</modelVersion>
47+
<parent>
48+
<groupId>net.wasdev.maven.parent</groupId>
49+
<artifactId>parent</artifactId>
50+
<version>1.4</version>
51+
</parent>
52+
<artifactId>my-artifact</artifactId>
53+
</project>
54+
"""
55+
)
56+
);
57+
}
58+
59+
@Test
60+
void noChangeParentArtifactId() {
61+
rewriteRun(
62+
spec -> spec.recipeFromResources("org.openrewrite.java.migrate.WasDevMvnChangeParentArtifactId"),
63+
//language=XML
64+
pomXml(
65+
"""
66+
<project>
67+
<modelVersion>4.0.0</modelVersion>
68+
<parent>
69+
<groupId>net.wasdev.maven.parent</groupId>
70+
<artifactId>parent</artifactId>
71+
<version>1.4</version>
72+
</parent>
73+
<artifactId>my-artifact</artifactId>
74+
</project>
75+
"""
76+
)
77+
);
78+
}
79+
}

0 commit comments

Comments
 (0)