diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java new file mode 100644 index 000000000..82db3824a --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelper.java @@ -0,0 +1,56 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * 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 + * + * https://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.springframework.sbm.boot.upgrade_27_30.report.helper; + +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.project.resource.RewriteSourceFileHolder; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +public class BannerSupportHelper implements SpringBootUpgradeReportSection.Helper> { + + private List foundBanners; + + @Override + public String getDescription() { + return ""; + } + + @Override + public boolean evaluate(ProjectContext context) { + foundBanners = context + .getProjectResources() + .stream() + .map(RewriteSourceFileHolder::getAbsolutePath) + .filter(absolutePath -> absolutePath.toString() + .matches(".*banner.(jpg|gif|png)$") + ) + .collect(Collectors.toList()); + return !foundBanners.isEmpty(); + } + + @Override + public Map> getData(ProjectContext context) { + + return Map.of("files", foundBanners.stream().map(Path::toString).collect(Collectors.toList())); + } +} diff --git a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java index 252cff578..2bc60459c 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java +++ b/components/sbm-recipes-boot-upgrade/src/main/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/ChangesToDataPropertiesHelper.java @@ -19,11 +19,9 @@ import lombok.RequiredArgsConstructor; import org.springframework.sbm.boot.properties.api.SpringBootApplicationProperties; import org.springframework.sbm.boot.properties.search.SpringBootApplicationPropertiesResourceListFilter; -import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportAction; import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportSection; import org.springframework.sbm.build.migration.conditions.NoDependencyExistMatchingRegex; import org.springframework.sbm.engine.context.ProjectContext; -import org.springframework.sbm.engine.recipe.Condition; import java.nio.file.Path; import java.util.ArrayList; diff --git a/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/boot-new-report.yaml b/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/boot-new-report.yaml index 301f35e82..9d6e55f7c 100644 --- a/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/boot-new-report.yaml +++ b/components/sbm-recipes-boot-upgrade/src/main/resources/recipes/boot-new-report.yaml @@ -2,7 +2,7 @@ description: Create a report for Spring Boot Upgrade from 2.7.x to 3.0.x condition: type: org.springframework.sbm.boot.common.conditions.IsSpringBootProject - versionPattern: "2\\.4\\..*|2\\.5\\..*" + versionPattern: "2\\.7\\..*" actions: @@ -18,7 +18,7 @@ = Spring Boot 3 Upgrade Report <#if contributors?has_content> <#list contributors as contributor> - ${contributor.name}<#sep>, + ${contributor.name}<#sep>, :source-highlighter: highlight.js @@ -113,7 +113,24 @@ contributors: - "Fabian Krüger[@fabapp2]" + - title: Banner support + helper: org.springframework.sbm.boot.upgrade_27_30.report.helper.BannerSupportHelper + change: |- + Support for image-based application banners has been removed. banner.gif, banner.jpg, and banner.png + files are now ignored and should be replaced with a text-based banner.txt file. + affected: |- + The scan found banner image files here: + + <#list files as file> + * ${file} + + remediation: |- + remove image banners and replace it with text-banner with banner.txt file + gitHubIssue: 150 + recipe: boot-2.7-3.0-upgrade-report + contributors: + - "Sandeep Nagaraj[@sanagaraj-pivotal]" footer: |- We want to say thank you to all Contributors: - Generated by Spring Boot Migrator (experimental) \ No newline at end of file + Generated by Spring Boot Migrator (experimental) diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/ChangesToDataPropertiesReportTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/ChangesToDataPropertiesReportTest.java index 4185ad350..2afc33992 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/ChangesToDataPropertiesReportTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/ChangesToDataPropertiesReportTest.java @@ -62,8 +62,8 @@ void changesToDataPropertiesSection_renders() { ==== Remediation Either add `spring-data` dependency, rename the property or remove it in case it's not required anymore. - """, Map.of("PATH", Path - .of(".").toAbsolutePath().resolve(TestProjectContext.getDefaultProjectRoot()).toString())); + """, + Map.of("PATH", Path.of(".").toAbsolutePath().resolve(TestProjectContext.getDefaultProjectRoot()).toString())); } @Test diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java index f3ae42d77..8077942af 100644 --- a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/SpringBootUpgradeReportActionTest.java @@ -47,6 +47,7 @@ void renderReport() throws IOException { """ [[index]] = Spring Boot 3 Upgrade Report + Sandeep Nagaraj, Fabian Krüger :source-highlighter: highlight.js :highlightjs-languages: java @@ -76,7 +77,7 @@ void renderReport() throws IOException { | Revision | Scanned project not under Git | Coordinate | `com.example:dummy-root:0.1.0-SNAPSHOT` | Boot version | `2.7.3` - | Changes | 2 + | Changes | 3 |=== The application was scanned and matched against the changes listed in the @@ -132,6 +133,7 @@ void renderReport() throws IOException { Generated by Spring Boot Migrator (experimental) """; + SpringBootUpgradeReportTestSupport.generatedReport() .fromProjectContext(context) .shouldRenderAs(expectedOutput, Map.of("PATH", Path.of(".").toAbsolutePath().resolve(TestProjectContext.getDefaultProjectRoot()).toString())); @@ -141,4 +143,4 @@ Generated by Spring Boot Migrator (experimental) Files.writeString(Path.of(".").toAbsolutePath().resolve("report.html"), context.getProjectResources().get(3).print(), StandardOpenOption.TRUNCATE_EXISTING); } -} \ No newline at end of file +} diff --git a/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelperTest.java b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelperTest.java new file mode 100644 index 000000000..cdf14ee4f --- /dev/null +++ b/components/sbm-recipes-boot-upgrade/src/test/java/org/springframework/sbm/boot/upgrade_27_30/report/helper/BannerSupportHelperTest.java @@ -0,0 +1,61 @@ +/* + * Copyright 2021 - 2022 the original author or authors. + * + * 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 + * + * https://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.springframework.sbm.boot.upgrade_27_30.report.helper; + +import org.junit.jupiter.api.Test; +import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportTestSupport; +import org.springframework.sbm.engine.context.ProjectContext; +import org.springframework.sbm.project.resource.TestProjectContext; + +import java.nio.file.Path; +import java.util.Map; + +public class BannerSupportHelperTest { + + @Test + public void rendersBannerSupportInformation() { + ProjectContext context = TestProjectContext.buildProjectContext() + .addProjectResource("src/main/resources/banner.gif", "gif-banner") + .addProjectResource("src/main/resources/banner.jpg", "jpg-banner") + .addProjectResource("src/main/com/test/banner.java","class banner {}") + .build(); + + SpringBootUpgradeReportTestSupport + .generatedSection("Banner support") + .fromProjectContext(context) + .shouldRenderAs( + """ + === Banner support + Issue: https://github.com/spring-projects-experimental/spring-boot-migrator/issues/150[#150], Contributors: https://github.com/sanagaraj-pivotal[@sanagaraj-pivotal^, role="ext-link"] + + ==== What Changed + Support for image-based application banners has been removed. banner.gif, banner.jpg, and banner.png\s + files are now ignored and should be replaced with a text-based banner.txt file. + + ==== Why is the application affected + The scan found banner image files here: + + * /src/main/resources/banner.gif + * /src/main/resources/banner.jpg + + ==== Remediation + remove image banners and replace it with text-banner with banner.txt file + + """, + Map.of("PATH", Path.of(".").toAbsolutePath().resolve(TestProjectContext.getDefaultProjectRoot()).toString())); + } +}