Skip to content

Commit 5c0539e

Browse files
authored
Also change Gradle classifier for Apache Shiro (#939)
1 parent 1f41048 commit 5c0539e

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

src/main/resources/META-INF/rewrite/jakarta-ee-10.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ recipeList:
504504
groupId: org.apache.shiro
505505
artifactId: "*"
506506
newClassifier: jakarta
507+
- org.openrewrite.gradle.ChangeDependencyClassifier:
508+
groupId: org.apache.shiro
509+
artifactId: "*"
510+
newClassifier: jakarta
507511
- org.openrewrite.java.dependencies.UpgradeDependencyVersion:
508512
groupId: org.apache.shiro
509513
artifactId: "*"
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright 2024 the original author or authors.
3+
* <p>
4+
* Licensed under the Moderne Source Available License (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://docs.moderne.io/licensing/moderne-source-available-license
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.jakarta;
17+
18+
import org.junit.jupiter.api.Test;
19+
import org.openrewrite.DocumentExample;
20+
import org.openrewrite.test.RecipeSpec;
21+
import org.openrewrite.test.RewriteTest;
22+
23+
import static org.assertj.core.api.Assertions.assertThat;
24+
import static org.openrewrite.gradle.Assertions.buildGradle;
25+
import static org.openrewrite.gradle.toolingapi.Assertions.withToolingApi;
26+
import static org.openrewrite.maven.Assertions.pomXml;
27+
28+
class UpdateApacheShiroDependenciesTest implements RewriteTest {
29+
30+
@Override
31+
public void defaults(RecipeSpec spec) {
32+
spec.recipeFromResources("org.openrewrite.java.migrate.jakarta.UpdateApacheShiroDependencies");
33+
}
34+
35+
@DocumentExample
36+
@Test
37+
void migrateShiroDependenciesMaven() {
38+
rewriteRun(
39+
//language=xml
40+
pomXml(
41+
"""
42+
<project>
43+
<groupId>com.example.shiro</groupId>
44+
<artifactId>shiro-legacy</artifactId>
45+
<version>1.0.0</version>
46+
<dependencies>
47+
<dependency>
48+
<groupId>org.apache.shiro</groupId>
49+
<artifactId>shiro-core</artifactId>
50+
<version>1.13.0</version>
51+
</dependency>
52+
<dependency>
53+
<groupId>org.apache.shiro</groupId>
54+
<artifactId>shiro-web</artifactId>
55+
<version>1.13.0</version>
56+
</dependency>
57+
</dependencies>
58+
</project>
59+
""",
60+
spec -> spec.after(pom -> assertThat(pom)
61+
.containsPattern("<version>2.0.\\d+</version>")
62+
.contains("<classifier>jakarta</classifier>")
63+
.actual())
64+
)
65+
);
66+
}
67+
68+
@Test
69+
void migrateShiroDependenciesGradle() {
70+
rewriteRun(
71+
spec -> spec.beforeRecipe(withToolingApi()),
72+
buildGradle(
73+
//language=groovy
74+
"""
75+
plugins {
76+
id("java-library")
77+
}
78+
repositories {
79+
mavenCentral()
80+
}
81+
dependencies {
82+
implementation 'org.apache.shiro:shiro-core:1.13.0'
83+
implementation 'org.apache.shiro:shiro-web:1.13.0'
84+
}
85+
""",
86+
spec -> spec.after(gradle -> assertThat(gradle)
87+
.containsPattern("2.0.\\d+:jakarta")
88+
.actual())
89+
)
90+
);
91+
}
92+
}

0 commit comments

Comments
 (0)