|
17 | 17 |
|
18 | 18 | import org.junit.jupiter.api.Test; |
19 | 19 | import org.openrewrite.DocumentExample; |
| 20 | +import org.openrewrite.marker.BuildTool; |
20 | 21 | import org.openrewrite.test.RecipeSpec; |
21 | 22 | import org.openrewrite.test.RewriteTest; |
| 23 | +import org.openrewrite.Tree; |
22 | 24 |
|
23 | 25 | import static org.assertj.core.api.Assertions.assertThat; |
| 26 | +import static org.openrewrite.gradle.toolingapi.Assertions.withToolingApi; |
24 | 27 | import static org.openrewrite.java.Assertions.mavenProject; |
25 | 28 | import static org.openrewrite.maven.Assertions.pomXml; |
| 29 | +import static org.openrewrite.properties.Assertions.properties; |
| 30 | +import static org.openrewrite.test.SourceSpecs.other; |
| 31 | +import static org.openrewrite.test.SourceSpecs.text; |
26 | 32 |
|
27 | 33 | class UpgradeToJava25Test implements RewriteTest { |
28 | 34 |
|
@@ -106,6 +112,38 @@ void upgradesMavenPluginsForJava25() { |
106 | 112 | ); |
107 | 113 | } |
108 | 114 |
|
| 115 | + @Test |
| 116 | + void upgradesGradleWrapperForJava25() { |
| 117 | + rewriteRun( |
| 118 | + spec -> spec.recipeFromResources("org.openrewrite.java.migrate.UpgradePluginsForJava25") |
| 119 | + .beforeRecipe(withToolingApi()) |
| 120 | + .allSources(source -> source.markers(new BuildTool(Tree.randomId(), BuildTool.Type.Gradle, "8.5"))), |
| 121 | + properties( |
| 122 | + """ |
| 123 | + distributionBase=GRADLE_USER_HOME |
| 124 | + distributionPath=wrapper/dists |
| 125 | + distributionUrl=https\\://services.gradle.org/distributions/gradle-8.5-bin.zip |
| 126 | + zipStoreBase=GRADLE_USER_HOME |
| 127 | + zipStorePath=wrapper/dists |
| 128 | + """, |
| 129 | + spec -> spec.path("gradle/wrapper/gradle-wrapper.properties") |
| 130 | + .after(actual -> { |
| 131 | + assertThat(actual).containsPattern("gradle-9\\.1\\.\\d+-bin\\.zip"); |
| 132 | + return actual; |
| 133 | + }) |
| 134 | + ), |
| 135 | + text("", spec -> spec.path("gradlew").after(a -> { |
| 136 | + assertThat(a).isNotEmpty(); |
| 137 | + return a + "\n"; |
| 138 | + })), |
| 139 | + text("", spec -> spec.path("gradlew.bat").after(a -> { |
| 140 | + assertThat(a).isNotEmpty(); |
| 141 | + return a + "\n"; |
| 142 | + })), |
| 143 | + other("", spec -> spec.path("gradle/wrapper/gradle-wrapper.jar")) |
| 144 | + ); |
| 145 | + } |
| 146 | + |
109 | 147 | @Test |
110 | 148 | void addsLombokAnnotationProcessor() { |
111 | 149 | rewriteRun( |
|
0 commit comments