Skip to content

Commit

Permalink
Merge pull request quarkusio#19760 from aloubyansky/exclude-jline-fro…
Browse files Browse the repository at this point in the history
…m-maven-plugin

Fix dev mode launch on Windows, replace jline with Aesh in the quarkus-maven-plugin
  • Loading branch information
aloubyansky authored Aug 30, 2021
2 parents 48b2980 + 0cfb90e commit 45511d9
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 121 deletions.
4 changes: 0 additions & 4 deletions build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -512,10 +512,6 @@
<exclude>org.jboss.resteasy:resteasy-context-propagation</exclude>
<exclude>com.google.android:annotations</exclude>
<exclude>org.codehaus.mojo:animal-sniffer-annotations</exclude>
<!-- JLine 2.x (EOLed) version shouldn't be pulled in,
to prevent version compatibility issues with the
Jansi library shipped in Maven -->
<exclude>jline:jline</exclude>
</excludes>
<includes>
<!-- this is for REST Assured -->
Expand Down
28 changes: 28 additions & 0 deletions devtools/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,34 @@
</resource>
</resources>
<plugins>
<!-- Jansi is shaded to workaround a classloading issue on Windows, see https://github.com/quarkusio/quarkus/issues/19673 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>org.fusesource.jansi:jansi</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/MANIFEST.MF</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-metadata</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
Expand Down Expand Up @@ -193,9 +192,6 @@ public class CreateExtensionMojo extends AbstractMojo {
@Parameter(property = "artifactId")
String artifactId;

@Component
private Prompter prompter;

@Parameter(defaultValue = "${project}")
protected MavenProject project;

Expand Down Expand Up @@ -267,19 +263,20 @@ private void promptValues() throws MojoExecutionException {
return;
}
try {

final Prompter prompter = new Prompter();
if (project == null || !project.getArtifactId().endsWith("quarkus-parent")) {
if (isBlank(quarkusVersion)) {
quarkusVersion = getPluginVersion();
}
if (isBlank(groupId)) {
groupId = prompter.promptWithDefaultValue("Set the extension groupId", "org.acme");
prompter.addPrompt("Set the extension groupId: ", "org.acme", input -> groupId = input);
}
}
autoComputeQuarkiverseExtensionId();
if (isBlank(extensionId)) {
extensionId = prompter.prompt("Set the extension id");
prompter.addPrompt("Set the extension id: ", input -> extensionId = input);
}
prompter.collectInput();
} catch (IOException e) {
throw new MojoExecutionException("Unable to get user input", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ public class CreateProjectMojo extends AbstractMojo {
@Parameter(defaultValue = "${repositorySystemSession}", readonly = true)
private RepositorySystemSession repoSession;

@Component
private Prompter prompter;

@Component
private MavenVersionEnforcer mavenVersionEnforcer;

Expand Down Expand Up @@ -405,33 +402,30 @@ private void askTheUserForMissingValues() throws MojoExecutionException {
}

try {
final Prompter prompter = new Prompter();
if (isBlank(projectGroupId)) {
projectGroupId = prompter.promptWithDefaultValue("Set the project groupId",
DEFAULT_GROUP_ID);
prompter.addPrompt("Set the project groupId: ", DEFAULT_GROUP_ID, input -> projectGroupId = input);
}

if (isBlank(projectArtifactId)) {
projectArtifactId = prompter.promptWithDefaultValue("Set the project artifactId",
DEFAULT_ARTIFACT_ID);
prompter.addPrompt("Set the project artifactId: ", DEFAULT_ARTIFACT_ID, input -> projectArtifactId = input);
}

if (isBlank(projectVersion)) {
projectVersion = prompter.promptWithDefaultValue("Set the project version",
DEFAULT_VERSION);
prompter.addPrompt("Set the project version: ", DEFAULT_VERSION, input -> projectVersion = input);
}

if (!noCode && isBlank(example)) {
if (extensions.isEmpty()) {
extensions = Arrays
.stream(prompter
.promptWithDefaultValue("What extensions do you wish to add (comma separated list)",
DEFAULT_EXTENSIONS)
.split(","))
.map(String::trim).filter(Predicate.not(String::isEmpty)).collect(Collectors.toSet());
prompter.addPrompt("What extensions do you wish to add (comma separated list): ", DEFAULT_EXTENSIONS,
input -> extensions = Arrays
.stream(input.split(","))
.map(String::trim).filter(Predicate.not(String::isEmpty)).collect(Collectors.toSet()));
}
String answer = prompter.promptWithDefaultValue(
"Would you like some code to start (yes), or just an empty Quarkus project (no)", "yes");
noCode = answer.startsWith("n");
prompter.addPrompt("Would you like some code to start (yes), or just an empty Quarkus project (no): ", "yes",
input -> noCode = input.startsWith("n"));

prompter.collectInput();
}
} catch (IOException e) {
throw new MojoExecutionException("Unable to get user input", e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,72 @@
package io.quarkus.maven.components;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

import org.codehaus.plexus.component.annotations.Component;
import org.aesh.readline.Readline;
import org.aesh.readline.ReadlineBuilder;
import org.aesh.readline.tty.terminal.TerminalConnection;

/**
* Prompt implementation.
*
* @author <a href="http://escoffier.me">Clement Escoffier</a>
*/
@Component(role = Prompter.class, instantiationStrategy = "per-lookup")
public class Prompter extends io.quarkus.devtools.utils.Prompter {
public class Prompter {

private static class Prompt {
private final String prompt;
private final String defaultValue;
private final Consumer<String> inputConsumer;

public Prompt(String prompt, String defaultValue, Consumer<String> inputConsumer) {
this.prompt = prompt;
this.defaultValue = defaultValue;
this.inputConsumer = inputConsumer;
}
}

private final List<Prompt> prompts = new ArrayList<>();

public Prompter() throws IOException {
super();
}

public Prompter addPrompt(String prompt, Consumer<String> inputConsumer) {
prompts.add(new Prompt(prompt, null, inputConsumer));
return this;
}

public Prompter addPrompt(String prompt, String defaultValue, Consumer<String> inputConsumer) {
prompts.add(new Prompt(prompt, defaultValue, inputConsumer));
return this;
}

public void collectInput() throws IOException {
if (prompts.isEmpty()) {
return;
}
final TerminalConnection connection = new TerminalConnection();
try {
read(connection, ReadlineBuilder.builder().enableHistory(false).build(), prompts.iterator());
connection.openBlocking();
} finally {
connection.close();
}
}

private static void read(TerminalConnection connection, Readline readline, Iterator<Prompt> prompts) {
final Prompt prompt = prompts.next();
readline.readline(connection, prompt.prompt, input -> {
prompt.inputConsumer.accept(
(input == null || input.isBlank()) && prompt.defaultValue != null ? prompt.defaultValue : input);
if (!prompts.hasNext()) {
connection.close();
} else {
read(connection, readline, prompts);
}
});
}
}
4 changes: 0 additions & 4 deletions independent-projects/arc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@
<exclude>org.slf4j:slf4j-jdk14</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>org.slf4j:slf4j-log4j13</exclude>
<!-- JLine 2.x (EOLed) version shouldn't be pulled in,
to prevent version compatibility issues with the
Jansi library shipped in Maven -->
<exclude>jline:jline</exclude>
</excludes>
</bannedDependencies>
</rules>
Expand Down
4 changes: 0 additions & 4 deletions independent-projects/bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,6 @@
<exclude>org.slf4j:slf4j-jdk14</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>org.slf4j:slf4j-log4j13</exclude>
<!-- JLine 2.x (EOLed) version shouldn't be pulled in,
to prevent version compatibility issues with the
Jansi library shipped in Maven -->
<exclude>jline:jline</exclude>
</excludes>
</bannedDependencies>
</rules>
Expand Down
4 changes: 0 additions & 4 deletions independent-projects/qute/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,6 @@
<exclude>org.slf4j:slf4j-jdk14</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>org.slf4j:slf4j-log4j13</exclude>
<!-- JLine 2.x (EOLed) version shouldn't be pulled in,
to prevent version compatibility issues with the
Jansi library shipped in Maven -->
<exclude>jline:jline</exclude>
</excludes>
</bannedDependencies>
</rules>
Expand Down
4 changes: 0 additions & 4 deletions independent-projects/resteasy-reactive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -364,10 +364,6 @@
<exclude>org.slf4j:slf4j-jdk14</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>org.slf4j:slf4j-log4j13</exclude>
<!-- JLine 2.x (EOLed) version shouldn't be pulled in,
to prevent version compatibility issues with the
Jansi library shipped in Maven -->
<exclude>jline:jline</exclude>
</excludes>
</bannedDependencies>
</rules>
Expand Down
5 changes: 0 additions & 5 deletions independent-projects/tools/devtools-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,6 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-devtools-codestarts</artifactId>
</dependency>
<!-- user prompt -->
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand Down

This file was deleted.

10 changes: 0 additions & 10 deletions independent-projects/tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
<scala-plugin.version>4.4.0</scala-plugin.version>

<!-- Versions -->
<jline.version>3.20.0</jline.version>
<assertj.version>3.20.2</assertj.version>
<jackson.version>2.12.5</jackson.version>
<jakarta.enterprise.cdi-api.version>2.0.2</jakarta.enterprise.cdi-api.version>
Expand Down Expand Up @@ -130,11 +129,6 @@
<artifactId>quarkus-devtools-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jline</groupId>
<artifactId>jline</artifactId>
<version>${jline.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down Expand Up @@ -310,10 +304,6 @@
<exclude>org.slf4j:slf4j-jdk14</exclude>
<exclude>org.slf4j:slf4j-log4j12</exclude>
<exclude>org.slf4j:slf4j-log4j13</exclude>
<!-- JLine 2.x (EOLed) version shouldn't be pulled in,
to prevent version compatibility issues with the
Jansi library shipped in Maven -->
<exclude>jline:jline</exclude>
</excludes>
</bannedDependencies>
</rules>
Expand Down

0 comments on commit 45511d9

Please sign in to comment.