Skip to content

Commit

Permalink
Fix build and run on Windows (spring-projects-experimental#91)
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
fabapp2 authored and ravigkant committed May 9, 2022
1 parent 19b882c commit 8fb42f0
Show file tree
Hide file tree
Showing 60 changed files with 963 additions and 670 deletions.
4 changes: 3 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ e.g.: `apply initialize-spring-boot-migration` +
Spring Boot Migrator will now apply the migrations defined in the recipe to the codebase.
* To get help when using SBM use the `help` command

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

NOTE: **The OpenRewrite `rewrite-java-11` module uses JDK internals and thus requires the project to run with JDK 11.**


=== Building from source
Expand Down
10 changes: 0 additions & 10 deletions applications/spring-shell/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@
<artifactId>sbm-recipes-spring-cloud</artifactId>
<version>0.10.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-json</artifactId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,45 +35,47 @@
@RequiredArgsConstructor
public class ScanShellCommand {

private final ScanCommand scanCommand;
private final ScanCommand scanCommand;

private final ApplicableRecipeListRenderer applicableRecipeListRenderer;
private final ApplicableRecipeListRenderer applicableRecipeListRenderer;

private final ApplicableRecipeListCommand applicableRecipeListCommand;
private final ApplicableRecipeListCommand applicableRecipeListCommand;

private final ProjectContextHolder contextHolder;
private final ProjectContextHolder contextHolder;
private final PreconditionVerificationRenderer preconditionVerificationRenderer;
private final ScanCommandHeaderRenderer scanCommandHeaderRenderer;
private final ConsolePrinter consolePrinter;
private final ScanCommandHeaderRenderer scanCommandHeaderRenderer;
private final ConsolePrinter consolePrinter;

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


List<Resource> resources = scanCommand.scanProjectRoot(projectRoot);
String scanCommandHeader = scanCommandHeaderRenderer.renderHeader(projectRoot);
PreconditionVerificationResult result = scanCommand.checkPreconditions(projectRoot, resources);
String renderedPreconditionCheckResults = preconditionVerificationRenderer.renderPreconditionCheckResults(result);
AttributedStringBuilder stringBuilder = new AttributedStringBuilder();
String output = stringBuilder
.append(scanCommandHeader)
.append(renderedPreconditionCheckResults)
.toAnsi();
List<Resource> resources = scanCommand.scanProjectRoot(projectRoot);
String scanCommandHeader = scanCommandHeaderRenderer.renderHeader(projectRoot);
PreconditionVerificationResult result = scanCommand.checkPreconditions(projectRoot, resources);
String renderedPreconditionCheckResults = preconditionVerificationRenderer.renderPreconditionCheckResults(result);
AttributedStringBuilder stringBuilder = new AttributedStringBuilder();
String output = stringBuilder
.append(scanCommandHeader)
.ansiAppend(renderedPreconditionCheckResults)
.toAttributedString().toAnsi();

consolePrinter.println(output);
consolePrinter.println(output);

stringBuilder = new AttributedStringBuilder();
if ( ! result.hasError()) {
stringBuilder = new AttributedStringBuilder();
if (!result.hasError()) {
ProjectContext projectContext = scanCommand.execute(projectRoot);
contextHolder.setProjectContext(projectContext);
List<Recipe> recipes = applicableRecipeListCommand.execute(projectContext);
AttributedString recipeList = applicableRecipeListRenderer.render(recipes);
stringBuilder.append(recipeList);
}

return stringBuilder.toAttributedString();
}
return stringBuilder.toAttributedString().toAnsi();
}

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

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

import java.nio.file.Path;

@Component
public class StringToPathConverter implements Converter<String, Path> {
@Override
public Path convert(String source) {
return Path.of(source);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public String render() {
AttributedStringBuilder builder = new AttributedStringBuilder();
builder.style(AttributedStyle.DEFAULT.bold().foreground(Colors.rgbColor("green")));
builder.append("[ok]");
return " ".repeat(indent.get()) + " " + builder.toAnsi() + " " + logMessage;
return " ".repeat(indent.get()) + " " + builder.toAttributedString().toAnsi() + " " + logMessage;
}

public String renderError() {
Expand All @@ -51,7 +51,7 @@ public String renderError() {
.style(AttributedStyle.DEFAULT)
.append(" ")
.append(logMessage);
return builder.toAnsi();
return builder.toAttributedString().toAnsi();
}

public String renderWarning() {
Expand All @@ -63,6 +63,6 @@ public String renderWarning() {
.style(AttributedStyle.DEFAULT)
.append(" ")
.append(logMessage);
return builder.toAnsi();
return builder.toAttributedString().toAnsi();
}
}
18 changes: 12 additions & 6 deletions applications/spring-shell/src/main/resources/banner.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,15 @@
|_| |___/ |___/

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

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

THANK YOU!

Use "help" command to list all of the available commands.

Properties:
-----------
Git Support enabled: ${sbm.gitSupportEnabled}
Expand All @@ -40,4 +38,12 @@ Base Package: ${sbm.defaultBasePackage}

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


Get Started:
------------
Type

"help" - to display a list all of the available commands.
"scan <dir>" - to scan an application

--------------------------------------------------------------------------------------------------
Loading

0 comments on commit 8fb42f0

Please sign in to comment.