Skip to content

Commit b33e5fa

Browse files
committed
Move JLine related APIs to a separate module
1 parent c339b01 commit b33e5fa

File tree

319 files changed

+1066
-1022
lines changed

Some content is hidden

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

319 files changed

+1066
-1022
lines changed

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989

9090
<modules>
9191
<module>spring-shell-core</module>
92+
<module>spring-shell-jline</module>
9293
<module>spring-shell-test</module>
9394
<module>spring-shell-autoconfigure</module>
9495
<module>spring-shell-test-autoconfigure</module>

spring-shell-autoconfigure/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,14 @@
4848
<optional>true</optional>
4949
</dependency>
5050

51+
<!-- Optional dependencies -->
52+
<dependency>
53+
<groupId>org.springframework.shell</groupId>
54+
<artifactId>spring-shell-jline</artifactId>
55+
<version>${project.parent.version}</version>
56+
<optional>true</optional>
57+
</dependency>
58+
5159
<!-- Test dependencies -->
5260
<dependency>
5361
<groupId>org.springframework.boot</groupId>

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ComponentFlowAutoConfiguration.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import org.springframework.context.annotation.Scope;
2828
import org.springframework.core.annotation.Order;
2929
import org.springframework.core.io.ResourceLoader;
30-
import org.springframework.shell.core.tui.component.flow.ComponentFlow;
31-
import org.springframework.shell.core.tui.component.flow.ComponentFlow.Builder;
32-
import org.springframework.shell.core.tui.style.TemplateExecutor;
30+
import org.springframework.shell.jline.tui.component.flow.ComponentFlow;
31+
import org.springframework.shell.jline.tui.component.flow.ComponentFlow.Builder;
32+
import org.springframework.shell.jline.tui.style.TemplateExecutor;
3333

3434
/**
3535
* {@link EnableAutoConfiguration Auto-configuration} for {@link ComponentFlow}.

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ComponentFlowCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package org.springframework.shell.boot;
1717

18-
import org.springframework.shell.core.tui.component.flow.ComponentFlow;
18+
import org.springframework.shell.jline.tui.component.flow.ComponentFlow;
1919

2020
/**
2121
* Callback interface that can be used to customize a {@link ComponentFlow.Builder}.

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/JLineShellAutoConfiguration.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import org.springframework.beans.factory.annotation.Value;
4141
import org.springframework.boot.autoconfigure.AutoConfiguration;
4242
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
43-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
4443
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4544
import org.springframework.context.annotation.Bean;
4645
import org.springframework.context.annotation.Configuration;
@@ -49,8 +48,9 @@
4948
import org.springframework.shell.core.command.Command;
5049
import org.springframework.shell.core.command.CommandRegistry;
5150
import org.springframework.shell.core.config.UserConfigPathProvider;
52-
import org.springframework.shell.core.jline.ExtendedDefaultParser;
53-
import org.springframework.shell.core.jline.PromptProvider;
51+
import org.springframework.shell.jline.ExtendedDefaultParser;
52+
import org.springframework.shell.jline.JLineInputProvider;
53+
import org.springframework.shell.jline.PromptProvider;
5454
import org.springframework.util.StringUtils;
5555

5656
/**
@@ -62,17 +62,10 @@
6262
*/
6363
@AutoConfiguration
6464
@EnableConfigurationProperties(SpringShellProperties.class)
65-
@ConditionalOnProperty(prefix = "spring.shell.interactive.type", name = "jline", havingValue = "true")
6665
public class JLineShellAutoConfiguration {
6766

6867
private final static Log log = LogFactory.getLog(JLineShellAutoConfiguration.class);
6968

70-
private Terminal terminal;
71-
72-
private Parser parser;
73-
74-
private CommandRegistry commandRegistry;
75-
7669
private org.jline.reader.History jLineHistory;
7770

7871
@Value("${spring.application.name:spring-shell}.log")
@@ -82,12 +75,8 @@ public class JLineShellAutoConfiguration {
8275

8376
private UserConfigPathProvider userConfigPathProvider;
8477

85-
public JLineShellAutoConfiguration(Terminal terminal, Parser parser, CommandRegistry commandRegistry,
86-
org.jline.reader.History jLineHistory, SpringShellProperties springShellProperties,
87-
UserConfigPathProvider userConfigPathProvider) {
88-
this.terminal = terminal;
89-
this.parser = parser;
90-
this.commandRegistry = commandRegistry;
78+
public JLineShellAutoConfiguration(org.jline.reader.History jLineHistory,
79+
SpringShellProperties springShellProperties, UserConfigPathProvider userConfigPathProvider) {
9180
this.jLineHistory = jLineHistory;
9281
this.springShellProperties = springShellProperties;
9382
this.userConfigPathProvider = userConfigPathProvider;
@@ -99,7 +88,7 @@ public void onContextClosedEvent(ContextClosedEvent event) throws IOException {
9988
}
10089

10190
@Bean
102-
public LineReader lineReader() {
91+
public LineReader lineReader(Terminal terminal, Parser parser, CommandRegistry commandRegistry) {
10392
LineReaderBuilder lineReaderBuilder = LineReaderBuilder.builder()
10493
.terminal(terminal)
10594
.appName("Spring Shell")
@@ -158,6 +147,11 @@ public void setErrorIndex(int errorIndex) {
158147
return lineReader;
159148
}
160149

150+
@Bean
151+
public JLineInputProvider inputProvider(LineReader lineReader) {
152+
return new JLineInputProvider(lineReader);
153+
}
154+
161155
@Bean(destroyMethod = "close")
162156
public Terminal terminal(ObjectProvider<TerminalCustomizer> customizers) {
163157
try {

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ShellRunnerAutoConfiguration.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,21 @@
1717

1818
import org.springframework.boot.ApplicationRunner;
1919
import org.springframework.boot.autoconfigure.AutoConfiguration;
20+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2021
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
2123
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2224
import org.springframework.context.annotation.Bean;
25+
import org.springframework.context.annotation.Import;
2326
import org.springframework.shell.core.ConsoleInputProvider;
2427
import org.springframework.shell.core.NonInteractiveShellRunner;
2528
import org.springframework.shell.core.ShellRunner;
2629
import org.springframework.shell.core.SystemShellRunner;
2730
import org.springframework.shell.core.command.CommandParser;
2831
import org.springframework.shell.core.command.CommandRegistry;
2932
import org.springframework.shell.core.command.DefaultCommandParser;
30-
import org.springframework.shell.core.jline.JLineInputProvider;
31-
import org.springframework.shell.core.jline.JLineShellRunner;
33+
import org.springframework.shell.jline.JLineInputProvider;
34+
import org.springframework.shell.jline.JLineShellRunner;
3235

3336
@AutoConfiguration
3437
public class ShellRunnerAutoConfiguration {
@@ -40,15 +43,14 @@ public ApplicationRunner springShellApplicationRunner(ShellRunner shellRunner) {
4043
}
4144

4245
@Bean
43-
@ConditionalOnProperty(prefix = "spring.shell.interactive.type", name = "system", havingValue = "true",
44-
matchIfMissing = true)
46+
@ConditionalOnMissingClass("org.springframework.shell.jline.DefaultJLineShellConfiguration")
4547
public ShellRunner systemShellRunner(ConsoleInputProvider consoleInputProvider, CommandParser commandParser,
4648
CommandRegistry commandRegistry) {
4749
return new SystemShellRunner(consoleInputProvider, commandParser, commandRegistry);
4850
}
4951

5052
@Bean
51-
@ConditionalOnProperty(prefix = "spring.shell.interactive.type", name = "jline", havingValue = "true")
53+
@ConditionalOnClass(name = "org.springframework.shell.jline.JLineInputProvider")
5254
public ShellRunner jlineShellRunner(JLineInputProvider inputProvider, CommandParser commandParser,
5355
CommandRegistry commandRegistry) {
5456
return new JLineShellRunner(inputProvider, commandParser, commandRegistry);

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/SpringShellProperties.java

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,6 @@ public static class Interactive {
131131

132132
private boolean enabled = true;
133133

134-
private Type type = Type.SYSTEM;
135-
136134
public boolean isEnabled() {
137135
return enabled;
138136
}
@@ -141,20 +139,6 @@ public void setEnabled(boolean enabled) {
141139
this.enabled = enabled;
142140
}
143141

144-
public Type getType() {
145-
return type;
146-
}
147-
148-
public void setType(Type type) {
149-
this.type = type;
150-
}
151-
152-
public enum Type {
153-
154-
SYSTEM, JLINE
155-
156-
}
157-
158142
}
159143

160144
public static class Theme {

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/TerminalUIAutoConfiguration.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2424
import org.springframework.context.annotation.Bean;
2525
import org.springframework.context.annotation.Scope;
26-
import org.springframework.shell.core.tui.component.ViewComponentBuilder;
27-
import org.springframework.shell.core.tui.component.ViewComponentExecutor;
28-
import org.springframework.shell.core.tui.component.view.TerminalUI;
29-
import org.springframework.shell.core.tui.component.view.TerminalUIBuilder;
30-
import org.springframework.shell.core.tui.component.view.TerminalUICustomizer;
31-
import org.springframework.shell.core.tui.style.ThemeActive;
32-
import org.springframework.shell.core.tui.style.ThemeResolver;
26+
import org.springframework.shell.jline.tui.component.ViewComponentBuilder;
27+
import org.springframework.shell.jline.tui.component.ViewComponentExecutor;
28+
import org.springframework.shell.jline.tui.component.view.TerminalUI;
29+
import org.springframework.shell.jline.tui.component.view.TerminalUIBuilder;
30+
import org.springframework.shell.jline.tui.component.view.TerminalUICustomizer;
31+
import org.springframework.shell.jline.tui.style.ThemeActive;
32+
import org.springframework.shell.jline.tui.style.ThemeResolver;
3333

3434
@AutoConfiguration
3535
@ConditionalOnClass(TerminalUI.class)

spring-shell-autoconfigure/src/main/java/org/springframework/shell/boot/ThemingAutoConfiguration.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2121
import org.springframework.boot.context.properties.EnableConfigurationProperties;
2222
import org.springframework.context.annotation.Bean;
23-
import org.springframework.shell.core.tui.style.TemplateExecutor;
24-
import org.springframework.shell.core.tui.style.Theme;
25-
import org.springframework.shell.core.tui.style.ThemeActive;
26-
import org.springframework.shell.core.tui.style.ThemeRegistry;
27-
import org.springframework.shell.core.tui.style.ThemeResolver;
28-
import org.springframework.shell.core.tui.style.ThemeSettings;
23+
import org.springframework.shell.jline.tui.style.TemplateExecutor;
24+
import org.springframework.shell.jline.tui.style.Theme;
25+
import org.springframework.shell.jline.tui.style.ThemeActive;
26+
import org.springframework.shell.jline.tui.style.ThemeRegistry;
27+
import org.springframework.shell.jline.tui.style.ThemeResolver;
28+
import org.springframework.shell.jline.tui.style.ThemeSettings;
2929
import org.springframework.util.StringUtils;
3030

3131
@AutoConfiguration

spring-shell-core/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@
4141
<artifactId>spring-messaging</artifactId>
4242
<version>${spring-framework.version}</version>
4343
</dependency>
44-
<dependency>
45-
<groupId>org.jline</groupId>
46-
<artifactId>jline</artifactId>
47-
<version>${jline.version}</version>
48-
</dependency>
4944
<dependency>
5045
<groupId>org.antlr</groupId>
5146
<artifactId>ST4</artifactId>

0 commit comments

Comments
 (0)