From ad4a76cd0c46ec77500c050873c9185910021af7 Mon Sep 17 00:00:00 2001 From: Martijn Dashorst Date: Sat, 31 Oct 2026 23:36:49 +0100 Subject: [PATCH] Let the Wicket migration recipes upgrade the org.apache.wicket dependencies MigrateToWicket10 and MigrateToWicket11 end with an UpgradeDependencyVersion step for org.apache.wicket:* that carries versionPattern: -SNAPSHOT. OpenRewrite discards snapshot, milestone and release candidate versions before it applies a versionPattern, so a release range combined with -SNAPSHOT matches no version at all, whether the project resolves from a release or a snapshot repository. The step never changed anything. A project migrated with either recipe kept its old wicket-core and the other org.apache.wicket artifacts, while the remaining steps did run: the Java baseline, the type changes and, for MigrateToWicket11, the move of wicket-metrics to the experimental.wicket11 groupId at 11.x. The result was a project mixing old core artifacts with new code changes, and the recipe gave no sign of it. The versionPattern is removed from both steps, so they select the latest release of the target line. Running either recipe now also upgrades the org.apache.wicket dependencies, or the property that holds their version. MigrateToWicket10Test#migrateDependencies had been disabled until the first 10.x release and never re-enabled, which is how this went unnoticed. It is enabled again, with its expectation corrected: the version regex captured the closing tag, and the expected pom lacked the maven.compiler.release property that UpgradeToJava17 adds. MigrateToWicket11Test is new and resolves wicket-core and wicket-metrics from a small file-based repository next to the test, with Maven Central and the local repository switched off, so it does not depend on what has been released. GitHub issue #1739 See also GitHub issue #1738 for wicket-10.x Co-Authored-By: Claude Opus 5.5 --- .../resources/META-INF/rewrite/wicket.yml | 2 - .../migration/MigrateToWicket10Test.java | 9 +- .../migration/MigrateToWicket11Test.java | 126 ++++++++++++++++++ .../10.12.0/wicket-metrics-10.12.0.pom | 24 ++++ .../wicket-metrics/maven-metadata-local.xml | 28 ++++ .../11.0.0/wicket-metrics-11.0.0.pom | 24 ++++ .../wicket-metrics/maven-metadata-local.xml | 28 ++++ .../10.12.0/wicket-core-10.12.0.pom | 24 ++++ .../wicket-core/11.0.0/wicket-core-11.0.0.pom | 24 ++++ .../wicket-core/maven-metadata-local.xml | 29 ++++ 10 files changed, 312 insertions(+), 6 deletions(-) create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket11Test.java create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/10.12.0/wicket-metrics-10.12.0.pom create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/maven-metadata-local.xml create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/11.0.0/wicket-metrics-11.0.0.pom create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/maven-metadata-local.xml create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/10.12.0/wicket-core-10.12.0.pom create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/11.0.0/wicket-core-11.0.0.pom create mode 100644 wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/maven-metadata-local.xml diff --git a/wicket-migration/src/main/resources/META-INF/rewrite/wicket.yml b/wicket-migration/src/main/resources/META-INF/rewrite/wicket.yml index 73aea2ac7e3..1571984622b 100644 --- a/wicket-migration/src/main/resources/META-INF/rewrite/wicket.yml +++ b/wicket-migration/src/main/resources/META-INF/rewrite/wicket.yml @@ -35,7 +35,6 @@ recipeList: groupId: org.apache.wicket artifactId: "*" newVersion: 10.x - versionPattern: -SNAPSHOT - org.openrewrite.maven.UpgradeDependencyVersion: groupId: org.apache.wicket.experimental.wicket9 artifactId: "*" @@ -139,5 +138,4 @@ recipeList: groupId: org.apache.wicket artifactId: "*" newVersion: 11.x - versionPattern: -SNAPSHOT --- diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket10Test.java b/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket10Test.java index 6bce2f1c571..91fb6007a33 100644 --- a/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket10Test.java +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket10Test.java @@ -16,7 +16,6 @@ package org.apache.wicket.migration; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; import org.openrewrite.config.Environment; import org.openrewrite.java.JavaParser; @@ -78,7 +77,6 @@ class ATest { } @Test - @Disabled("Requires first release of 10.x before we can update the version") void migrateDependencies() { //language=xml rewriteRun( @@ -104,7 +102,7 @@ void migrateDependencies() { """, spec -> spec.after(pom -> { - Matcher version = Pattern.compile("10\\..+").matcher(pom); + Matcher version = Pattern.compile("(10\\.[^<]+)").matcher(pom); assertThat(version.find()).describedAs("Expected 10.x in %s", pom).isTrue(); return String.format(""" @@ -112,6 +110,9 @@ void migrateDependencies() { com.example wicket 1.0.0 + + 17 + org.apache.wicket @@ -120,7 +121,7 @@ void migrateDependencies() { - """, version.group(0)); + """, version.group(1)); }) ) ) diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket11Test.java b/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket11Test.java new file mode 100644 index 00000000000..d4f446f63c8 --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/MigrateToWicket11Test.java @@ -0,0 +1,126 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.wicket.migration; + +import org.junit.jupiter.api.Test; +import org.openrewrite.ExecutionContext; +import org.openrewrite.InMemoryExecutionContext; +import org.openrewrite.config.Environment; +import org.openrewrite.maven.MavenExecutionContextView; +import org.openrewrite.maven.tree.MavenRepository; +import org.openrewrite.test.RecipeSpec; +import org.openrewrite.test.RewriteTest; + +import java.net.URISyntaxException; +import java.util.List; + +import static org.openrewrite.java.Assertions.mavenProject; +import static org.openrewrite.maven.Assertions.pomXml; + +/** + * Resolves the Wicket artifacts from the {@code maven-repository} fixture next to this class + * only, so the outcome does not depend on what Maven Central or the local repository contain. + */ +class MigrateToWicket11Test implements RewriteTest { + + @Override + public void defaults(RecipeSpec spec) { + spec + .executionContext(fixtureRepositoryOnly()) + .recipe(Environment.builder() + .scanRuntimeClasspath() + .build() + .activateRecipes("org.apache.wicket.MigrateToWicket11")); + } + + private static ExecutionContext fixtureRepositoryOnly() { + String uri; + try { + uri = MigrateToWicket11Test.class.getResource("maven-repository").toURI().toString(); + } catch (URISyntaxException e) { + throw new IllegalStateException(e); + } + + ExecutionContext ctx = new InMemoryExecutionContext(t -> { + throw new AssertionError(t); + }); + MavenExecutionContextView.view(ctx) + .setAddCentralRepository(false) + .setAddLocalRepository(false) + .setRepositories(List.of(MavenRepository.builder() + .id("fixture") + .uri(uri) + .knownToExist(true) + .build())); + return ctx; + } + + @Test + void migrateDependencies() { + //language=xml + rewriteRun( + mavenProject("any-project", + pomXml(""" + + 4.0.0 + com.example + wicket + 1.0.0 + + + org.apache.wicket + wicket-core + 10.12.0 + + + org.apache.wicket.experimental.wicket10 + wicket-metrics + 10.12.0 + + + + """, + """ + + 4.0.0 + com.example + wicket + 1.0.0 + + 21 + + + + org.apache.wicket + wicket-core + 11.0.0 + + + org.apache.wicket.experimental.wicket11 + wicket-metrics + 11.0.0 + + + + """ + ) + ) + ); + } + +} diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/10.12.0/wicket-metrics-10.12.0.pom b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/10.12.0/wicket-metrics-10.12.0.pom new file mode 100644 index 00000000000..7c70cc11779 --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/10.12.0/wicket-metrics-10.12.0.pom @@ -0,0 +1,24 @@ + + + + 4.0.0 + org.apache.wicket.experimental.wicket10 + wicket-metrics + 10.12.0 + pom + diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/maven-metadata-local.xml b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/maven-metadata-local.xml new file mode 100644 index 00000000000..55a899cb7a5 --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket10/wicket-metrics/maven-metadata-local.xml @@ -0,0 +1,28 @@ + + + + org.apache.wicket.experimental.wicket10 + wicket-metrics + + 10.12.0 + 10.12.0 + + 10.12.0 + + + diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/11.0.0/wicket-metrics-11.0.0.pom b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/11.0.0/wicket-metrics-11.0.0.pom new file mode 100644 index 00000000000..ee7b0d77ec5 --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/11.0.0/wicket-metrics-11.0.0.pom @@ -0,0 +1,24 @@ + + + + 4.0.0 + org.apache.wicket.experimental.wicket11 + wicket-metrics + 11.0.0 + pom + diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/maven-metadata-local.xml b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/maven-metadata-local.xml new file mode 100644 index 00000000000..1e91150a116 --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/experimental/wicket11/wicket-metrics/maven-metadata-local.xml @@ -0,0 +1,28 @@ + + + + org.apache.wicket.experimental.wicket11 + wicket-metrics + + 11.0.0 + 11.0.0 + + 11.0.0 + + + diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/10.12.0/wicket-core-10.12.0.pom b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/10.12.0/wicket-core-10.12.0.pom new file mode 100644 index 00000000000..3fc2b9af40f --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/10.12.0/wicket-core-10.12.0.pom @@ -0,0 +1,24 @@ + + + + 4.0.0 + org.apache.wicket + wicket-core + 10.12.0 + pom + diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/11.0.0/wicket-core-11.0.0.pom b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/11.0.0/wicket-core-11.0.0.pom new file mode 100644 index 00000000000..fff5758cdc8 --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/11.0.0/wicket-core-11.0.0.pom @@ -0,0 +1,24 @@ + + + + 4.0.0 + org.apache.wicket + wicket-core + 11.0.0 + pom + diff --git a/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/maven-metadata-local.xml b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/maven-metadata-local.xml new file mode 100644 index 00000000000..4767e9af19e --- /dev/null +++ b/wicket-migration/src/test/java/org/apache/wicket/migration/maven-repository/org/apache/wicket/wicket-core/maven-metadata-local.xml @@ -0,0 +1,29 @@ + + + + org.apache.wicket + wicket-core + + 11.0.0 + 11.0.0 + + 10.12.0 + 11.0.0 + + +