Skip to content

Spring Boot 3 Upgrade Report #553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
9b9e3e7
Web app demo
fabapp2 Nov 11, 2022
5a8e488
Moved add milestone repository for dependencies and plugins to dedica…
fabapp2 Nov 22, 2022
c163425
Moved dependency version updates to dedicated recipe
fabapp2 Nov 14, 2022
1841329
Moved dependency version updates to dedicated recipe
fabapp2 Nov 14, 2022
e108bd7
Moved recipe for javax to jakarta package change to dedicated recipe
fabapp2 Nov 14, 2022
f4198d9
Moved recipe migration of spring.data properties to dedicated recipe
fabapp2 Nov 14, 2022
a7e3c28
Moved recipe for PagingAndSoprtingRepository to dedicated recipe
fabapp2 Nov 14, 2022
14c0d5a
Moved new Spring Boot 3.0 upgrade recipes to dedicated dir
fabapp2 Nov 14, 2022
158c5fe
Renamed Helper to something meaningful and fixed condition
fabapp2 Nov 14, 2022
3d27fa1
Added missing properties to applicaiton.properties to enable git support
fabapp2 Nov 14, 2022
573772b
Replaced tags with pinned sha for GH actions
fabapp2 Nov 14, 2022
33c4315
Prevent empty commits, closes #527
fabapp2 Nov 17, 2022
7cb1184
Move ImprovedConstructorBinding into dedicated recipe and fix condition
fabapp2 Nov 17, 2022
5f35d4c
Fix condition for PagingAndSorting migration
fabapp2 Nov 17, 2022
9a08ea7
Fix condition for migrate jakarta packages migration
fabapp2 Nov 17, 2022
14f6ff3
Adjust replace button in SpringBootUpgradeReportTestSupport
fabapp2 Nov 17, 2022
3f478d1
Rename report recipe
fabapp2 Nov 17, 2022
f38608e
Fix conditoon for PagingAndSortingHelper and use in migration
fabapp2 Nov 17, 2022
0ceeef0
Add withBootParentOf to TestProjectContext
fabapp2 Nov 17, 2022
ac183cd
Fixed recipes names (#555)
ashakirin Nov 15, 2022
7869384
Fixing PagingAndSortingHelperTest conforming to new finder (#556)
sanagaraj-pivotal Nov 15, 2022
fda8bbf
Add recipe to remove image banner, closes #558
fabapp2 Nov 15, 2022
fb8dca7
Moved recipes for Boot 2.7 to 3.0 upgrade to respective dirs
fabapp2 Nov 16, 2022
8214116
Add report section and recipe to bump boot version to 3.0
fabapp2 Nov 16, 2022
20b3cc7
Add a flag to not re-generate report on first request
fabapp2 Nov 16, 2022
ea37ee5
Enhanced DependencyHelper and TestProjectContext to allow adding mana…
fabapp2 Nov 16, 2022
3ee5379
Add upgrade dependencies report and migration
fabapp2 Nov 17, 2022
ecf85d0
Fix typo
fabapp2 Nov 16, 2022
fd0eb07
Renamed rest-service to spring-boot-upgrade
fabapp2 Nov 16, 2022
7526de8
Fix BannerSupportReportSectionTest
fabapp2 Nov 17, 2022
4ff6296
Remove freemarker markup from expected output fixes SpringMvcAndWebFl…
fabapp2 Nov 17, 2022
f86f2c9
Replace ST parsing with string replace
fabapp2 Nov 17, 2022
5485956
rework rendering the list of authors
fabapp2 Nov 16, 2022
653d2ce
Add demo for new Spring Boot Upgrade report
fabapp2 Nov 16, 2022
c746757
Set triggermesh flag to false on test teardown
fabapp2 Nov 22, 2022
6164940
Moved report recipe to report package (again)
fabapp2 Nov 22, 2022
13cdc39
Delete obsolete file
fabapp2 Nov 22, 2022
bcc3e04
Merge branch 'main' into webapp-demo
fabapp2 Nov 22, 2022
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
2 changes: 0 additions & 2 deletions applications/rest-service/commands.txt

This file was deleted.

This file was deleted.

43 changes: 0 additions & 43 deletions applications/rest-service/src/main/resources/banner.txt

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>rest-service</artifactId>
<artifactId>spring-boot-upgrade</artifactId>

<packaging>jar</packaging>

Expand Down Expand Up @@ -71,10 +71,12 @@
<artifactId>spring-asciidoctor-backends</artifactId>
</dependency>
</requiresUnpack>
<finalName>spring-boot-upgrade</finalName>
</configuration>
</execution>
</executions>
<configuration>
<finalName>spring-boot-upgrade</finalName>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/*
* 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;

import lombok.Getter;
import lombok.Setter;
import lombok.Value;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.sbm.boot.upgrade_27_30.report.SpringBootUpgradeReportRenderer;
import org.springframework.sbm.engine.commands.ApplyCommand;
import org.springframework.sbm.engine.context.ProjectContext;
import org.springframework.sbm.engine.context.ProjectContextHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@CrossOrigin
class ReportController{

@Autowired
private ApplyCommand applyCommand;
@Autowired
private ReportHolder reportHolder;

@Autowired
private ProjectContextHolder contextHolder;

public static final String REPORT_RECIPE = "sbu30-report";

private boolean isInitialReport = true;

@GetMapping(path = "/spring-boot-upgrade", produces = MediaType.TEXT_HTML_VALUE)
@ResponseBody
public String upgrade() {
// Urgh... that's nasty
if(!isInitialReport) {
applyCommand.execute(contextHolder.getProjectContext(), REPORT_RECIPE);
}
isInitialReport = false;
return reportHolder.getReport();
}

@PostMapping(path = "/spring-boot-upgrade", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, produces = MediaType.TEXT_HTML_VALUE)
@ResponseBody
public String applyRecipes(@RequestParam("recipeNames[]") String[] recipeNames) {
ProjectContext context = contextHolder.getProjectContext();
List.of(recipeNames).forEach(recipeName -> applyCommand.execute(context, recipeName));
applyCommand.execute(context, REPORT_RECIPE);
return reportHolder.getReport();
}

@PostMapping(path = "/spring-boot-upgrade")
@ResponseBody
public void applyRecipes2(@RequestBody Recipe recipeNames) {
ProjectContext context = contextHolder.getProjectContext();
recipeNames.getRecipes().forEach(
recipeName -> applyCommand.execute(context, recipeName)
);
applyCommand.execute(context, REPORT_RECIPE);
}

@Getter
@Setter
static class Recipe {
private List<String> recipes;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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;

import lombok.RequiredArgsConstructor;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.annotation.Configuration;
import org.springframework.sbm.engine.commands.ApplyCommand;
import org.springframework.sbm.engine.commands.ScanCommand;
import org.springframework.sbm.engine.context.ProjectContext;
import org.springframework.sbm.engine.context.ProjectContextHolder;

@Configuration
@RequiredArgsConstructor
public class SpringBootMigratorRunner implements ApplicationRunner {

private final ScanCommand scanCommand;
private final ProjectContextHolder contextHolder;
private final ApplyCommand applyCommand;
private final String REPORT_RECIPE = "sbu30-report";

@Override
public void run(ApplicationArguments args) {
if (args.getSourceArgs().length == 0) {
System.err.println("PLease provide the path to the application as parameter.");
return;
}
String applicationPath = args.getSourceArgs()[0];
System.out.println("Scanning " + applicationPath);
ProjectContext context = scanCommand.execute(applicationPath);
contextHolder.setProjectContext(context);
applyCommand.execute(contextHolder.getProjectContext(), REPORT_RECIPE);
System.out.println("finished scan. Please open: http://localhost:8080/spring-boot-upgrade");
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
* @author Fabian Krüger
*/
@SpringBootApplication
public class SpringBootUpgradeReportApp {
public static void main(String[] args) {
try {
SpringApplication.run(SpringBootUpgradeReportApp.class, args);
} catch (Exception exception) {
System.err.println(exception.getMessage());
exception.printStackTrace();
}
}

@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**").allowedMethods("*");
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@
@Component
@Primary
public class SpringBootUpgradeReportStringRenderer implements SpringBootUpgradeReportRenderer {

@Autowired
private ReportHolder reportHolder;
@Override
public void processReport(String renderedReport) {
String htmlReport = UpgradeReportUtil.renderHtml(renderedReport);
String closingHeadTag = "</head>";

String additionalHeader =
// "<link rel=\"stylesheet\" href=\"css/button.css\">\n" +
// "<script src=\"js/setup2.js\"></script>\n" +
// "<script src=\"js/site2.js\"></script>\n" +

// "<script src=\"js/java.min.js\"></script>\n";
// htmlReport = htmlReport.replace(closingHeadTag, additionalHeader + closingHeadTag);

htmlReport = htmlReport.replace("</body>", """
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<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>
<script src="js/recipe.js"></script>
</body>
""");
reportHolder.setReport(htmlReport);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
spring.profiles.active=default, core
spring.application.name=spring-boot-upgrade-report
# toggle support for git to sync and auto-commit
sbm.gitSupportEnabled=true
logging.level.org=ERROR
logging.level.org.springframework.sbm.logging.MethodCallTraceInterceptor=DEBUG
logging.level.org.springframework.sbm.logging.StopWatchTraceInterceptor=DEBUG
logging.level.org.springframework=ERROR
logging.level.org.openrewrite=ERROR
logging.level.org.springframework.sbm=ERROR
Loading