Skip to content

Commit

Permalink
Added Recipe for Migrating Dropwizard Dependencies (#510)
Browse files Browse the repository at this point in the history
* Added Recipe for Migrating Dropwizard Dependencies

* Resolved Feedback Comments

* Added Test for MigrateDropwizard Package Name Changes
  • Loading branch information
bsmahi authored Mar 22, 2024
1 parent 71f7cc8 commit 06556d2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/main/resources/META-INF/rewrite/spring-boot-30.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ recipeList:
- org.openrewrite.java.spring.boot3.SpringBootProperties_3_0
- org.openrewrite.java.spring.boot3.MigrateThymeleafDependencies
- org.openrewrite.java.spring.boot3.UpgradeSpringDoc_2
- org.openrewrite.java.spring.boot3.MigrateDropWizardDependencies
- org.openrewrite.java.spring.security6.UpgradeSpringSecurity_6_0
- org.openrewrite.java.spring.cloud2022.UpgradeSpringCloud_2022
- org.openrewrite.hibernate.MigrateToHibernate61
Expand Down Expand Up @@ -200,3 +201,30 @@ recipeList:
methodPattern: org.springdoc.core.models.GroupedOpenApi.Builder addOpenApiCustomiser(..)
newMethodName: addOpenApiCustomizer
matchOverrides: true
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.spring.boot3.MigrateDropWizardDependencies
displayName: Migrate dropWizard dependencies to Spring Boot 3.x
description: Migrate dropWizard dependencies to the new artifactId, since these are changed with Spring Boot 3.
tags:
- spring
- boot
- dropwizard
recipeList:
- org.openrewrite.java.ChangePackage:
oldPackageName: com.codahale.metrics.servlet
newPackageName: io.dropwizard.metrics.servlet
- org.openrewrite.java.ChangePackage:
oldPackageName: com.codahale.metrics.servlets
newPackageName: io.dropwizard.metrics.servlets
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
oldGroupId: io.dropwizard.metrics
oldArtifactId: metrics-servlet
newArtifactId: metrics-jakarta-servlet
newVersion: 4.2.xx
- org.openrewrite.maven.ChangeDependencyGroupIdAndArtifactId:
oldGroupId: io.dropwizard.metrics
oldArtifactId: metrics-servlets
newArtifactId: metrics-jakarta-servlets
newVersion: 4.2.xx
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2021 the original author or authors.
* <p>
* Licensed 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
* <p>
* https://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.openrewrite.java.spring.boot3;

import org.junit.jupiter.api.Test;
import org.openrewrite.config.Environment;
import org.openrewrite.java.JavaParser;
import org.openrewrite.test.RecipeSpec;
import org.openrewrite.test.RewriteTest;

import static org.openrewrite.java.Assertions.java;

class MigrateDropWizardDependenciesTest implements RewriteTest {

@Override
public void defaults(RecipeSpec spec) {
spec.recipe(Environment.builder()
.scanRuntimeClasspath("org.openrewrite.java.spring")
.build()
.activateRecipes("org.openrewrite.java.spring.boot3.MigrateDropWizardDependencies"))
.parser(JavaParser.fromJavaVersion().classpath("spring-boot", "spring-context", "spring-beans"));
}

@Test
void migrateDropWizardDependenciesPackageNames() {
java(
"""
import com.codahale.metrics.servlet.InstrumentedFilter;
import com.codahale.metrics.servlets.MetricsServlet;
""",
"""
import io.dropwizard.metrics.servlet.InstrumentedFilter;
import io.dropwizard.metrics.servlets.MetricsServlet;
""");
}
}

0 comments on commit 06556d2

Please sign in to comment.