Skip to content

Commit

Permalink
Merge pull request #14722 from ejba/fix-codestarts-icons-14219
Browse files Browse the repository at this point in the history
   Avoid print icons when running on Windows OS
  • Loading branch information
geoand authored Mar 2, 2021
2 parents 345be10 + d4ce954 commit 4056a98
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.quarkus.devtools.codestarts;

import io.smallrye.common.os.OS;

public enum CodestartType {
LANGUAGE(true, 1, "\uD83D\uDD20"),
BUILDTOOL(true, 2, "\uD83E\uDDF0"),
Expand All @@ -24,7 +26,7 @@ public boolean isBase() {
}

public String getIcon() {
return icon;
return OS.WINDOWS.isCurrent() ? ">>" : icon;
}

public int getProcessingOrder() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,12 @@ static void generateProject(final CodestartProjectDefinition projectDefinition,
});

processor.writeFiles();

log.info("\napplying codestarts...");
log.info(projectDefinition.getCodestarts().stream()
.map(c -> c.getType().getIcon() + " "
+ c.getName())
.collect(Collectors.joining("\n")));
.collect(Collectors.joining(System.lineSeparator())));
}

private static Map<String, String> mergeStrategies(CodestartProjectDefinition projectDefinition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public QuarkusCommandOutcome execute(QuarkusCommandInvocation invocation) throws
final CodestartProjectDefinition projectDefinition = catalog.createProject(input);
projectDefinition.generate(invocation.getQuarkusProject().getProjectDirPath());
invocation.log()
.info("\n-----------\n" + MessageIcons.NOOP_ICON + " "
.info("\n-----------\n" + MessageIcons.OK_ICON + " "
+ projectDefinition.getRequiredCodestart(CodestartType.PROJECT).getName()
+ " project has been successfully generated in:\n--> "
+ invocation.getQuarkusProject().getProjectDirPath().toString() + "\n-----------");
Expand Down
6 changes: 6 additions & 0 deletions independent-projects/tools/message-writer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<dependencies>
<dependency>
<groupId>io.smallrye.common</groupId>
<artifactId>smallrye-common-os</artifactId>
</dependency>
</dependencies>

<parent>
<groupId>io.quarkus</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
package io.quarkus.devtools.messagewriter;

public final class MessageIcons {
import io.smallrye.common.os.OS;

public static final String OK_ICON = "\u2705";
public static final String NOK_ICON = "\u274c";
public static final String NOOP_ICON = "\uD83D\uDC4D";
public static final String WARN_ICON = "\uD83D\uDD25";
public static final String ERROR_ICON = "\u2757";
public enum MessageIcons {

private MessageIcons() {
OK_ICON("\u2705", "[SUCCESS]"),
NOK_ICON("\u274c", "[FAILURE]"),
NOOP_ICON("\uD83D\uDC4D", ""),
WARN_ICON("\uD83D\uDD25", "[WARN]"),
ERROR_ICON("\u2757", "[ERROR]");

private String icon;
private String messageCode;

MessageIcons(String icon, String messageCode) {
this.icon = icon;
this.messageCode = messageCode;
}

@Override
public String toString() {
return OS.WINDOWS.isCurrent() ? messageCode : String.format("%s %s", messageCode, icon);
}
}
7 changes: 6 additions & 1 deletion independent-projects/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<maven-model-helper.version>18</maven-model-helper.version>
<commons-io.version>2.8.0</commons-io.version>
<quarkus-http.version>3.0.18.Final</quarkus-http.version>
<smallrye-commons.version>1.5.0</smallrye-commons.version>
</properties>
<modules>
<module>platform-descriptor-api</module>
Expand Down Expand Up @@ -204,6 +205,11 @@
<scope>test</scope>
<version>${quarkus.version}</version>
</dependency>
<dependency>
<groupId>io.smallrye.common</groupId>
<artifactId>smallrye-common-os</artifactId>
<version>${smallrye-commons.version}</version>
</dependency>
<!-- Jackson dependencies, imported as a BOM -->
<dependency>
<groupId>com.fasterxml.jackson</groupId>
Expand All @@ -212,7 +218,6 @@
<scope>import</scope>
<type>pom</type>
</dependency>

</dependencies>
</dependencyManagement>

Expand Down

0 comments on commit 4056a98

Please sign in to comment.