Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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: "*"
Expand Down Expand Up @@ -139,5 +138,4 @@ recipeList:
groupId: org.apache.wicket
artifactId: "*"
newVersion: 11.x
versionPattern: -SNAPSHOT
---
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -104,14 +102,17 @@ void migrateDependencies() {
</project>
""",
spec -> spec.after(pom -> {
Matcher version = Pattern.compile("10\\..+").matcher(pom);
Matcher version = Pattern.compile("<version>(10\\.[^<]+)</version>").matcher(pom);
assertThat(version.find()).describedAs("Expected 10.x in %s", pom).isTrue();
return String.format("""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>wicket</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.wicket</groupId>
Expand All @@ -120,7 +121,7 @@ void migrateDependencies() {
</dependency>
</dependencies>
</project>
""", version.group(0));
""", version.group(1));
})
)
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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("""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>wicket</artifactId>
<version>1.0.0</version>
<dependencies>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>10.12.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket.experimental.wicket10</groupId>
<artifactId>wicket-metrics</artifactId>
<version>10.12.0</version>
</dependency>
</dependencies>
</project>
""",
"""
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>wicket</artifactId>
<version>1.0.0</version>
<properties>
<maven.compiler.release>21</maven.compiler.release>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>11.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.wicket.experimental.wicket11</groupId>
<artifactId>wicket-metrics</artifactId>
<version>11.0.0</version>
</dependency>
</dependencies>
</project>
"""
)
)
);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.wicket.experimental.wicket10</groupId>
<artifactId>wicket-metrics</artifactId>
<version>10.12.0</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<metadata>
<groupId>org.apache.wicket.experimental.wicket10</groupId>
<artifactId>wicket-metrics</artifactId>
<versioning>
<latest>10.12.0</latest>
<release>10.12.0</release>
<versions>
<version>10.12.0</version>
</versions>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.wicket.experimental.wicket11</groupId>
<artifactId>wicket-metrics</artifactId>
<version>11.0.0</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<metadata>
<groupId>org.apache.wicket.experimental.wicket11</groupId>
<artifactId>wicket-metrics</artifactId>
<versioning>
<latest>11.0.0</latest>
<release>11.0.0</release>
<versions>
<version>11.0.0</version>
</versions>
</versioning>
</metadata>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>10.12.0</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>11.0.0</version>
<packaging>pom</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<metadata>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<versioning>
<latest>11.0.0</latest>
<release>11.0.0</release>
<versions>
<version>10.12.0</version>
<version>11.0.0</version>
</versions>
</versioning>
</metadata>
Loading