Skip to content

Commit 1edf37d

Browse files
authored
Spring Boot 3 Upgrade Report (#553)
* Spring Boot 3 Upgrade Report Web App * Section gets removed when running recipe succeeds, closes #551 * Move report generation into runner * Add button and change Controller to accept all applicable recipes * Commented out all code related to "run all recipes" button * Section fades out before being removed * Related section in sidebar fades out and gets removed * page scrolls to the next section * Moved add milestone repository for dependencies and plugins to dedicated recipe * Moved dependency version updates to dedicated recipe * Moved dependency version updates to dedicated recipe * Moved recipe for javax to jakarta package change to dedicated recipe * Moved recipe migration of spring.data properties to dedicated recipe * Moved recipe for PagingAndSoprtingRepository to dedicated recipe * Moved new Spring Boot 3.0 upgrade recipes to dedicated dir * Renamed Helper to something meaningful and fixed condition * Added missing properties to applicaiton.properties to enable git support * Replaced tags with pinned sha for GH actions * Prevent empty commits, closes #527 * Move ImprovedConstructorBinding into dedicated recipe and fix condition * Fix condition for PagingAndSorting migration * Fix condition for migrate jakarta packages migration * Adjust replace button in SpringBootUpgradeReportTestSupport * Rename report recipe * Fix conditoon for PagingAndSortingHelper and use in migration * Add withBootParentOf to TestProjectContext * TestProjectContext supports creating pom.xml with spring*boot*parent of given version * removed unused variable * Fixed recipes names (#555) * Fixing PagingAndSortingHelperTest conforming to new finder (#556) * Add recipe to remove image banner, closes #558 * Fixing TestProjectContext when used to create a multi*module project * Enhance PomBuilder to throw exception on API misuse * Enhance RecipeTestSupport to use with declarative rewrite recipe * Fix type check in ConditionDeserializer * Moved recipes for Boot 2.7 to 3.0 upgrade to respective dirs * Add report section and recipe to bump boot version to 3.0 * Add a flag to not re*generate report on first request * Enhanced DependencyHelper and TestProjectContext to allow adding managed dependencies without given version * Add upgrade dependencies report and migration * Fix typo * Renamed rest*service to spring*boot*upgrade * Fix BannerSupportReportSectionTest * Remove freemarker markup from expected output fixes SpringMvcAndWebFluxMatchinChnagesReportSectionTest * Replace ST parsing with string replace * rework rendering the list of authors * Add demo for new Spring Boot Upgrade report * Set triggermesh flag to false on test teardown * Moved report recipe to report package (again) * Delete obsolete file Co*authored*by: ashakirin <[email protected]> Co*authored*by: Sandeep Nagaraj <59915704+sanagaraj*[email protected]>
1 parent 772dc2d commit 1edf37d

File tree

72 files changed

+2113
-308
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+2113
-308
lines changed

applications/rest-service/commands.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

applications/rest-service/src/main/java/org/springframework/sbm/SpringBootMigratorServiceApp.java

Lines changed: 0 additions & 100 deletions
This file was deleted.

applications/rest-service/src/main/resources/banner.txt

Lines changed: 0 additions & 43 deletions
This file was deleted.

applications/rest-service/src/main/resources/static/css/site.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

applications/rest-service/pom.xml renamed to applications/spring-boot-upgrade/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<relativePath>../../pom.xml</relativePath>
2525
</parent>
2626

27-
<artifactId>rest-service</artifactId>
27+
<artifactId>spring-boot-upgrade</artifactId>
2828

2929
<packaging>jar</packaging>
3030

@@ -71,10 +71,12 @@
7171
<artifactId>spring-asciidoctor-backends</artifactId>
7272
</dependency>
7373
</requiresUnpack>
74-
<finalName>spring-boot-upgrade</finalName>
7574
</configuration>
7675
</execution>
7776
</executions>
77+
<configuration>
78+
<finalName>spring-boot-upgrade</finalName>
79+
</configuration>
7880
</plugin>
7981
</plugins>
8082
</build>
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import lombok.Getter;
19+
import lombok.Setter;
20+
import lombok.Value;
21+
import org.springframework.beans.factory.annotation.Autowired;
22+
import org.springframework.http.MediaType;
23+
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportRenderer;
24+
import org.springframework.sbm.engine.commands.ApplyCommand;
25+
import org.springframework.sbm.engine.context.ProjectContext;
26+
import org.springframework.sbm.engine.context.ProjectContextHolder;
27+
import org.springframework.stereotype.Controller;
28+
import org.springframework.web.bind.annotation.*;
29+
30+
import java.util.List;
31+
32+
@Controller
33+
@CrossOrigin
34+
class ReportController{
35+
36+
@Autowired
37+
private ApplyCommand applyCommand;
38+
@Autowired
39+
private ReportHolder reportHolder;
40+
41+
@Autowired
42+
private ProjectContextHolder contextHolder;
43+
44+
public static final String REPORT_RECIPE = "sbu30-report";
45+
46+
private boolean isInitialReport = true;
47+
48+
@GetMapping(path = "/spring-boot-upgrade", produces = MediaType.TEXT_HTML_VALUE)
49+
@ResponseBody
50+
public String upgrade() {
51+
// Urgh... that's nasty
52+
if(!isInitialReport) {
53+
applyCommand.execute(contextHolder.getProjectContext(), REPORT_RECIPE);
54+
}
55+
isInitialReport = false;
56+
return reportHolder.getReport();
57+
}
58+
59+
@PostMapping(path = "/spring-boot-upgrade", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE)
60+
@ResponseBody
61+
public String applyRecipes(@RequestParam("recipeNames[]") String[] recipeNames) {
62+
ProjectContext context = contextHolder.getProjectContext();
63+
List.of(recipeNames).forEach(recipeName -> applyCommand.execute(context, recipeName));
64+
applyCommand.execute(context, REPORT_RECIPE);
65+
return reportHolder.getReport();
66+
}
67+
68+
@PostMapping(path = "/spring-boot-upgrade")
69+
@ResponseBody
70+
public void applyRecipes2(@RequestBody Recipe recipeNames) {
71+
ProjectContext context = contextHolder.getProjectContext();
72+
recipeNames.getRecipes().forEach(
73+
recipeName -> applyCommand.execute(context, recipeName)
74+
);
75+
applyCommand.execute(context, REPORT_RECIPE);
76+
}
77+
78+
@Getter
79+
@Setter
80+
static class Recipe {
81+
private List<String> recipes;
82+
}
83+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import lombok.RequiredArgsConstructor;
19+
import org.springframework.boot.ApplicationArguments;
20+
import org.springframework.boot.ApplicationRunner;
21+
import org.springframework.context.annotation.Configuration;
22+
import org.springframework.sbm.engine.commands.ApplyCommand;
23+
import org.springframework.sbm.engine.commands.ScanCommand;
24+
import org.springframework.sbm.engine.context.ProjectContext;
25+
import org.springframework.sbm.engine.context.ProjectContextHolder;
26+
27+
@Configuration
28+
@RequiredArgsConstructor
29+
public class SpringBootMigratorRunner implements ApplicationRunner {
30+
31+
private final ScanCommand scanCommand;
32+
private final ProjectContextHolder contextHolder;
33+
private final ApplyCommand applyCommand;
34+
private final String REPORT_RECIPE = "sbu30-report";
35+
36+
@Override
37+
public void run(ApplicationArguments args) {
38+
if (args.getSourceArgs().length == 0) {
39+
System.err.println("PLease provide the path to the application as parameter.");
40+
return;
41+
}
42+
String applicationPath = args.getSourceArgs()[0];
43+
System.out.println("Scanning " + applicationPath);
44+
ProjectContext context = scanCommand.execute(applicationPath);
45+
contextHolder.setProjectContext(context);
46+
applyCommand.execute(contextHolder.getProjectContext(), REPORT_RECIPE);
47+
System.out.println("finished scan. Please open: http://localhost:8080/spring-boot-upgrade");
48+
}
49+
50+
51+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2021 - 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.sbm;
17+
18+
import org.springframework.boot.SpringApplication;
19+
import org.springframework.boot.autoconfigure.SpringBootApplication;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.web.servlet.config.annotation.CorsRegistry;
22+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
23+
24+
/**
25+
* @author Fabian Krüger
26+
*/
27+
@SpringBootApplication
28+
public class SpringBootUpgradeReportApp {
29+
public static void main(String[] args) {
30+
try {
31+
SpringApplication.run(SpringBootUpgradeReportApp.class, args);
32+
} catch (Exception exception) {
33+
System.err.println(exception.getMessage());
34+
exception.printStackTrace();
35+
}
36+
}
37+
38+
@Bean
39+
public WebMvcConfigurer corsConfigurer() {
40+
return new WebMvcConfigurer() {
41+
@Override
42+
public void addCorsMappings(CorsRegistry registry) {
43+
registry.addMapping("/**").allowedMethods("*");
44+
}
45+
};
46+
}
47+
}

applications/rest-service/src/main/java/org/springframework/sbm/SpringBootUpgradeReportStringRenderer.java renamed to applications/spring-boot-upgrade/src/main/java/org/springframework/sbm/SpringBootUpgradeReportStringRenderer.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,28 @@
2727
@Component
2828
@Primary
2929
public class SpringBootUpgradeReportStringRenderer implements SpringBootUpgradeReportRenderer {
30-
3130
@Autowired
3231
private ReportHolder reportHolder;
3332
@Override
3433
public void processReport(String renderedReport) {
3534
String htmlReport = UpgradeReportUtil.renderHtml(renderedReport);
35+
String closingHeadTag = "</head>";
36+
37+
String additionalHeader =
38+
// "<link rel=\"stylesheet\" href=\"css/button.css\">\n" +
39+
// "<script src=\"js/setup2.js\"></script>\n" +
40+
// "<script src=\"js/site2.js\"></script>\n" +
41+
42+
// "<script src=\"js/java.min.js\"></script>\n";
43+
// htmlReport = htmlReport.replace(closingHeadTag, additionalHeader + closingHeadTag);
44+
45+
htmlReport = htmlReport.replace("</body>", """
46+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
47+
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
48+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>
49+
<script src="js/recipe.js"></script>
50+
</body>
51+
""");
3652
reportHolder.setReport(htmlReport);
3753
}
3854
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring.profiles.active=default, core
2+
spring.application.name=spring-boot-upgrade-report
3+
# toggle support for git to sync and auto-commit
4+
sbm.gitSupportEnabled=true
5+
logging.level.org=ERROR
6+
logging.level.org.springframework.sbm.logging.MethodCallTraceInterceptor=DEBUG
7+
logging.level.org.springframework.sbm.logging.StopWatchTraceInterceptor=DEBUG
8+
logging.level.org.springframework=ERROR
9+
logging.level.org.openrewrite=ERROR
10+
logging.level.org.springframework.sbm=ERROR

0 commit comments

Comments
 (0)