Skip to content

Commit 1bb7afb

Browse files
committed
Code cleanup to remove dependency to plexus-utils
Closes #52
1 parent 9e9d267 commit 1bb7afb

File tree

11 files changed

+5
-25
lines changed

11 files changed

+5
-25
lines changed

plexus-interactivity-api/pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@
1313
<name>Plexus Default Interactivity Handler</name>
1414

1515
<dependencies>
16-
<dependency>
17-
<groupId>org.codehaus.plexus</groupId>
18-
<artifactId>plexus-utils</artifactId>
19-
<version>4.0.0</version>
20-
</dependency>
21-
2216
<!-- JLine is optional -->
2317
<dependency>
2418
<groupId>org.jline</groupId>

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/AbstractInputHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* Base input handler, implements a default <code>readMultipleLines</code>.
3333
*
3434
* @author Brett Porter
35-
* @version $Id$
3635
*/
3736
public abstract class AbstractInputHandler implements InputHandler {
3837
@Override

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultInputHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
* Default input handler, that uses the console.
3535
*
3636
* @author Brett Porter
37-
* @version $Id$
3837
*/
3938
@Named
4039
public class DefaultInputHandler extends AbstractInputHandler {

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultOutputHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
* Default output handler, that uses the console.
3333
*
3434
* @author Brett Porter
35-
* @version $Id$
3635
*/
3736
@Named
3837
public class DefaultOutputHandler implements OutputHandler {

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/DefaultPrompter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,10 @@
3131
import java.util.Iterator;
3232
import java.util.List;
3333

34-
import org.codehaus.plexus.util.StringUtils;
35-
3634
/**
3735
* Default prompter.
3836
*
3937
* @author Brett Porter
40-
* @version $Id$
4138
*/
4239
@Named
4340
public class DefaultPrompter implements Prompter {
@@ -76,11 +73,9 @@ public String prompt(String message, String defaultReply) throws PrompterExcepti
7673

7774
try {
7875
String line = inputHandler.readLine();
79-
80-
if (StringUtils.isEmpty(line)) {
76+
if (line == null || line.isEmpty()) {
8177
line = defaultReply;
8278
}
83-
8479
return line;
8580
} catch (IOException e) {
8681
throw new PrompterException("Failed to read user response", e);
@@ -109,7 +104,7 @@ public String prompt(String message, List<String> possibleValues, String default
109104
throw new PrompterException("Failed to read user response", e);
110105
}
111106

112-
if (StringUtils.isEmpty(line)) {
107+
if (line == null || line.isEmpty()) {
113108
line = defaultReply;
114109
}
115110

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/InputHandler.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929

3030
/**
3131
* Manage user input from different sources.
32-
*
3332
* TODO should this also echo any prompts before the input?
3433
* TODO should this validate the input, reprompt if required?
3534
* TODO readBoolean, readInt, readSingleChar - readLine's that parse the input
3635
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
37-
* @version $Id$
3836
*/
3937
public interface InputHandler {
4038
/**

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/OutputHandler.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
* Manage user output to different sources.
3131
*
3232
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
33-
* @version $Id$
3433
*/
3534
public interface OutputHandler {
3635
/**

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/Prompter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
* Prompt the user for input.
3131
*
3232
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
33-
* @version $Id$
3433
*/
3534
public interface Prompter {
3635
String prompt(String message) throws PrompterException;

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/PrompterException.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
* Error while prompting.
2929
*
3030
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
31-
* @version $Id$
3231
*/
3332
public class PrompterException extends Exception {
3433
public PrompterException(String message) {

plexus-interactivity-api/src/main/java/org/codehaus/plexus/components/interactivity/jline/JLineInputHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,16 @@
3636
* Default input handler, that uses the console.
3737
*
3838
* @author Brett Porter
39-
* @version $Id$
4039
*/
4140
@Named("jline")
4241
public class JLineInputHandler extends AbstractInputHandler {
43-
private LineReader consoleReader = LineReaderBuilder.builder().build();
42+
private final LineReader consoleReader = LineReaderBuilder.builder().build();
4443

4544
public String readLine() throws IOException {
4645
return consoleReader.readLine();
4746
}
4847

4948
public String readPassword() throws IOException {
50-
return consoleReader.readLine(new Character('*'));
49+
return consoleReader.readLine('*');
5150
}
5251
}

plexus-interactivity-api/src/test/java/org/codehaus/plexus/components/interactivity/DefaultPrompterComponentTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public class DefaultPrompterComponentTest extends InjectedTest {
3737
private Prompter prompter;
3838

3939
@Test
40-
void smoke() throws PrompterException {
40+
void smoke() {
4141
assertNotNull(prompter);
4242
}
4343
}

0 commit comments

Comments
 (0)