Skip to content

Commit cbfd2e5

Browse files
authored
Fix build and run on Windows (#91)
- Paths unified before applying matcher - Add LinuxWindowsPathUnifier - Remove emojis in banner - Fix problem with ignoredPaths property - Fix tests and use OS line endings - Fix MoveFile Action
1 parent a0707ec commit cbfd2e5

File tree

62 files changed

+967
-678
lines changed

Some content is hidden

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

62 files changed

+967
-678
lines changed

README.adoc

+3-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ e.g.: `apply initialize-spring-boot-migration` +
3737
Spring Boot Migrator will now apply the migrations defined in the recipe to the codebase.
3838
* To get help when using SBM use the `help` command
3939

40-
WARNING: **The OpenRewrite `rewrite-java-11` module uses JDK internals and thus requires the project to run with JDK 11.**
40+
NOTE: When using Windows you must either escape `\` or use `/` as path separator, e.g. `C:\\my\\app` or `C:/my/app`
41+
42+
NOTE: **The OpenRewrite `rewrite-java-11` module uses JDK internals and thus requires the project to run with JDK 11.**
4143

4244

4345
=== Building from source

applications/spring-shell/pom.xml

-10
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,6 @@
5454
<artifactId>sbm-recipes-spring-cloud</artifactId>
5555
<version>0.10.1-SNAPSHOT</version>
5656
</dependency>
57-
<dependency>
58-
<groupId>org.springframework.boot</groupId>
59-
<artifactId>spring-boot-starter-aop</artifactId>
60-
<exclusions>
61-
<exclusion>
62-
<groupId>org.springframework.boot</groupId>
63-
<artifactId>spring-boot-starter</artifactId>
64-
</exclusion>
65-
</exclusions>
66-
</dependency>
6757
<dependency>
6858
<groupId>org.springframework.boot</groupId>
6959
<artifactId>spring-boot-starter-json</artifactId>

applications/spring-shell/src/main/java/org/springframework/sbm/logging/MethodCallTraceInterceptor.java

-80
This file was deleted.

applications/spring-shell/src/main/java/org/springframework/sbm/logging/StopWatchTraceInterceptor.java

-78
This file was deleted.

applications/spring-shell/src/main/java/org/springframework/sbm/shell/ScanShellCommand.java

+26-24
Original file line numberDiff line numberDiff line change
@@ -35,45 +35,47 @@
3535
@RequiredArgsConstructor
3636
public class ScanShellCommand {
3737

38-
private final ScanCommand scanCommand;
38+
private final ScanCommand scanCommand;
3939

40-
private final ApplicableRecipeListRenderer applicableRecipeListRenderer;
40+
private final ApplicableRecipeListRenderer applicableRecipeListRenderer;
4141

42-
private final ApplicableRecipeListCommand applicableRecipeListCommand;
42+
private final ApplicableRecipeListCommand applicableRecipeListCommand;
4343

44-
private final ProjectContextHolder contextHolder;
44+
private final ProjectContextHolder contextHolder;
4545
private final PreconditionVerificationRenderer preconditionVerificationRenderer;
46-
private final ScanCommandHeaderRenderer scanCommandHeaderRenderer;
47-
private final ConsolePrinter consolePrinter;
46+
private final ScanCommandHeaderRenderer scanCommandHeaderRenderer;
47+
private final ConsolePrinter consolePrinter;
4848

49-
@ShellMethod(key = { "scan", "s" },
50-
value = "Scans the target project directory and get the list of applicable recipes.")
51-
public AttributedString scan(@ShellOption(defaultValue = ".",
52-
help = "The root directory of the target application.") String projectRoot) {
49+
@ShellMethod(key = {"scan", "s"},
50+
value = "Scans the target project directory and get the list of applicable recipes.")
51+
public String scan(
52+
@ShellOption(defaultValue = ".", help = "The root directory of the target application.")
53+
//@Pattern(regexp = "")
54+
String projectRoot) {
5355

5456

55-
List<Resource> resources = scanCommand.scanProjectRoot(projectRoot);
56-
String scanCommandHeader = scanCommandHeaderRenderer.renderHeader(projectRoot);
57-
PreconditionVerificationResult result = scanCommand.checkPreconditions(projectRoot, resources);
58-
String renderedPreconditionCheckResults = preconditionVerificationRenderer.renderPreconditionCheckResults(result);
59-
AttributedStringBuilder stringBuilder = new AttributedStringBuilder();
60-
String output = stringBuilder
61-
.append(scanCommandHeader)
62-
.append(renderedPreconditionCheckResults)
63-
.toAnsi();
57+
List<Resource> resources = scanCommand.scanProjectRoot(projectRoot);
58+
String scanCommandHeader = scanCommandHeaderRenderer.renderHeader(projectRoot);
59+
PreconditionVerificationResult result = scanCommand.checkPreconditions(projectRoot, resources);
60+
String renderedPreconditionCheckResults = preconditionVerificationRenderer.renderPreconditionCheckResults(result);
61+
AttributedStringBuilder stringBuilder = new AttributedStringBuilder();
62+
String output = stringBuilder
63+
.append(scanCommandHeader)
64+
.ansiAppend(renderedPreconditionCheckResults)
65+
.toAttributedString().toAnsi();
6466

65-
consolePrinter.println(output);
67+
consolePrinter.println(output);
6668

67-
stringBuilder = new AttributedStringBuilder();
68-
if ( ! result.hasError()) {
69+
stringBuilder = new AttributedStringBuilder();
70+
if (!result.hasError()) {
6971
ProjectContext projectContext = scanCommand.execute(projectRoot);
7072
contextHolder.setProjectContext(projectContext);
7173
List<Recipe> recipes = applicableRecipeListCommand.execute(projectContext);
7274
AttributedString recipeList = applicableRecipeListRenderer.render(recipes);
7375
stringBuilder.append(recipeList);
7476
}
7577

76-
return stringBuilder.toAttributedString();
77-
}
78+
return stringBuilder.toAttributedString().toAnsi();
79+
}
7880

7981
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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.shell.converter;
17+
18+
import org.springframework.core.convert.converter.Converter;
19+
import org.springframework.stereotype.Component;
20+
21+
import java.nio.file.Path;
22+
23+
@Component
24+
public class StringToPathConverter implements Converter<String, Path> {
25+
@Override
26+
public Path convert(String source) {
27+
return Path.of(source);
28+
}
29+
}

applications/spring-shell/src/main/java/org/springframework/sbm/shell/renderer/LogStep.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public String render() {
3939
AttributedStringBuilder builder = new AttributedStringBuilder();
4040
builder.style(AttributedStyle.DEFAULT.bold().foreground(Colors.rgbColor("green")));
4141
builder.append("[ok]");
42-
return " ".repeat(indent.get()) + " " + builder.toAnsi() + " " + logMessage;
42+
return " ".repeat(indent.get()) + " " + builder.toAttributedString().toAnsi() + " " + logMessage;
4343
}
4444

4545
public String renderError() {
@@ -51,7 +51,7 @@ public String renderError() {
5151
.style(AttributedStyle.DEFAULT)
5252
.append(" ")
5353
.append(logMessage);
54-
return builder.toAnsi();
54+
return builder.toAttributedString().toAnsi();
5555
}
5656

5757
public String renderWarning() {
@@ -63,6 +63,6 @@ public String renderWarning() {
6363
.style(AttributedStyle.DEFAULT)
6464
.append(" ")
6565
.append(logMessage);
66-
return builder.toAnsi();
66+
return builder.toAttributedString().toAnsi();
6767
}
6868
}

applications/spring-shell/src/main/resources/banner.txt

+12-6
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
|_| |___/ |___/
88

99
Find us...
10-
on GitHub: https://github.com/pivotal/spring-boot-migrator
10+
on GitHub: https://github.com/spring-projects-experimental/spring-boot-migrator
1111
on Slack: https://vmware.slack.com/archives/CKB9VJE68 #spring-boot-migrator
1212

13-
This project contains a lot of ❤️❤️❤️️ but still, there will be 🐞🐞🐞
14-
So please, give us Feedback: https://github.com/pivotal/spring-boot-migrator/issues
15-
Also if you 👍 or 👎 something or have an 💡
13+
This project contains a lot of love. But still, there will be bugs...
14+
So please, give us Feedback: https://github.com/spring-projects-experimental/spring-boot-migrator/issues
15+
Also, if you like the project please give a star on GitHub.
1616

1717
THANK YOU!
1818

19-
Use "help" command to list all of the available commands.
20-
2119
Properties:
2220
-----------
2321
Git Support enabled: ${sbm.gitSupportEnabled}
@@ -40,4 +38,12 @@ Base Package: ${sbm.defaultBasePackage}
4038

4139
Use -Dsbm.defaultBasePackage=com.acme.packagename as VM parameter on startup to set the property.
4240

41+
42+
Get Started:
43+
------------
44+
Type
45+
46+
"help" - to display a list all of the available commands.
47+
"scan <dir>" - to scan an application
48+
4349
--------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)