Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
cache: 'maven'

- name: Build with Maven
run: ./mvnw --no-transfer-progress --batch-mode --update-snapshots verify
run: ./mvnw --no-transfer-progress --batch-mode --update-snapshots verify -Pnullaway

10 changes: 10 additions & 0 deletions .mvn/jvm.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-opens jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
56 changes: 56 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
<commons-io.version>2.20.0</commons-io.version>
<slf4j.version>2.0.17</slf4j.version>
<jakarta.validation-api.version>3.1.1</jakarta.validation-api.version>
<errorprone.version>2.36.0</errorprone.version>
<nullaway.version>0.12.7</nullaway.version>
<jspecify.version>1.0.0</jspecify.version>

<!-- test dependencies -->
<jimfs.version>1.3.1</jimfs.version>
Expand Down Expand Up @@ -228,6 +231,59 @@
</plugins>
</build>

<profiles>
<profile>
<id>nullaway</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<showWarnings>true</showWarnings>

</configuration>
<executions>
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_core</artifactId>
<version>${errorprone.version}</version>
</path>
<path>
<groupId>com.uber.nullaway</groupId>
<artifactId>nullaway</artifactId>
<version>${nullaway.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-XDcompilePolicy=simple</arg>
<arg>--should-stop=ifError=FLOW</arg>
<arg>-Xplugin:ErrorProne -XepDisableAllChecks -Xep:NullAway:ERROR
-XepOpt:NullAway:OnlyNullMarked=true
-XepOpt:NullAway:CustomContractAnnotations=org.springframework.lang.Contract
</arg>
</compilerArgs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<repositories>
<repository>
<id>maven-central</id>
Expand Down
5 changes: 5 additions & 0 deletions spring-shell-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
<version>${spring-boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jspecify</groupId>
<artifactId>jspecify</artifactId>
<version>${jspecify.version}</version>
</dependency>

<!-- Test dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import org.springframework.shell.CompletionProposal;
import org.springframework.shell.Shell;

/**
* @author Piotr Olaszewski
*/
@AutoConfiguration
public class CompleterAutoConfiguration {

Expand All @@ -39,15 +42,17 @@ public class CompleterAutoConfiguration {

@Bean
public CompleterAdapter completer() {
CompleterAdapter completerAdapter = new CompleterAdapter();
completerAdapter.setShell(shell);
return completerAdapter;
return new CompleterAdapter(shell);
}

public static class CompleterAdapter implements Completer {

private Shell shell;

public CompleterAdapter(Shell shell) {
this.shell = shell;
}

@Override
public void complete(LineReader reader, ParsedLine line, List<Candidate> candidates) {
CompletingParsedLine cpl = (line instanceof CompletingParsedLine) ? ((CompletingParsedLine) line) : t -> t;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
import org.springframework.shell.config.UserConfigPathProvider;
import org.springframework.util.StringUtils;

/**
* @author Piotr Olaszewski
*/
@AutoConfiguration
@EnableConfigurationProperties(SpringShellProperties.class)
public class LineReaderAutoConfiguration {
Expand All @@ -59,7 +62,7 @@ public class LineReaderAutoConfiguration {
private org.jline.reader.History jLineHistory;

@Value("${spring.application.name:spring-shell}.log")
private String fallbackHistoryFileName;
private String fallbackHistoryFileName = "spring-shell.log";

private SpringShellProperties springShellProperties;
private UserConfigPathProvider userConfigPathProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,14 @@
*/
package org.springframework.shell.boot;

import org.jspecify.annotations.Nullable;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
* Configuration properties for shell.
*
* @author Janne Valkealahti
* @author Piotr Olaszewski
*/
@ConfigurationProperties(prefix = "spring.shell")
public class SpringShellProperties {
Expand Down Expand Up @@ -118,36 +120,36 @@ public void setContext(Context context) {

public static class Config {

private String env;
private String location;
private @Nullable String env;
private @Nullable String location;

public String getEnv() {
public @Nullable String getEnv() {
return env;
}

public void setEnv(String env) {
public void setEnv(@Nullable String env) {
this.env = env;
}

public String getLocation() {
public @Nullable String getLocation() {
return location;
}

public void setLocation(String location) {
public void setLocation(@Nullable String location) {
this.location = location;
}
}

public static class History {

private String name;
private @Nullable String name;
private boolean enabled = true;

public String getName() {
public @Nullable String getName() {
return name;
}

public void setName(String name) {
public void setName(@Nullable String name) {
this.name = name;
}

Expand Down Expand Up @@ -189,7 +191,7 @@ public void setEnabled(boolean enabled) {
public static class Noninteractive {

private boolean enabled = true;
private String primaryCommand;
private @Nullable String primaryCommand;

public boolean isEnabled() {
return enabled;
Expand All @@ -199,24 +201,24 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getPrimaryCommand() {
public @Nullable String getPrimaryCommand() {
return primaryCommand;
}

public void setPrimaryCommand(String primaryCommand) {
public void setPrimaryCommand(@Nullable String primaryCommand) {
this.primaryCommand = primaryCommand;
}
}

public static class Theme {

private String name;
private @Nullable String name;

public String getName() {
public @Nullable String getName() {
return name;
}

public void setName(String name) {
public void setName(@Nullable String name) {
this.name = name;
}
}
Expand Down Expand Up @@ -334,7 +336,7 @@ public void setEnabled(boolean enabled) {
public static class CompletionCommand {

private boolean enabled = true;
private String rootCommand;
private @Nullable String rootCommand;

public boolean isEnabled() {
return enabled;
Expand All @@ -344,11 +346,11 @@ public void setEnabled(boolean enabled) {
this.enabled = enabled;
}

public String getRootCommand() {
public @Nullable String getRootCommand() {
return rootCommand;
}

public void setRootCommand(String rootCommand) {
public void setRootCommand(@Nullable String rootCommand) {
this.rootCommand = rootCommand;
}
}
Expand Down Expand Up @@ -625,7 +627,7 @@ public void setClose(boolean close) {
}
}

public static enum OptionNamingCase {
public enum OptionNamingCase {
NOOP,
CAMEL,
SNAKE,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@
import org.springframework.shell.standard.commands.Stacktrace;
import org.springframework.shell.standard.commands.Version;
import org.springframework.shell.tui.style.TemplateExecutor;
import org.springframework.util.Assert;

/**
* Creates beans for standard commands.
*
* @author Eric Bottard
* @author Mahmoud Ben Hassine
* @author Piotr Olaszewski
*/
@AutoConfiguration
@ConditionalOnClass({ Help.Command.class })
Expand All @@ -57,7 +59,9 @@ public class StandardCommandsAutoConfiguration {
@ConditionalOnMissingBean(Help.Command.class)
@ConditionalOnProperty(prefix = "spring.shell.command.help", value = "enabled", havingValue = "true", matchIfMissing = true)
public Help help(SpringShellProperties properties, ObjectProvider<TemplateExecutor> templateExecutor) {
Help help = new Help(templateExecutor.getIfAvailable());
TemplateExecutor executor = templateExecutor.getIfAvailable();
Assert.notNull(executor, "'executor' must not be null");
Help help = new Help(executor);
if (properties.getCommand().getHelp().getGroupingMode() == GroupingMode.FLAT) {
help.setShowGroups(false);
}
Expand Down Expand Up @@ -105,15 +109,19 @@ public History historyCommand(org.jline.reader.History jLineHistory) {
@ConditionalOnMissingBean(Completion.Command.class)
@Conditional(OnCompletionCommandCondition.class)
public Completion completion(SpringShellProperties properties) {
return new Completion(properties.getCommand().getCompletion().getRootCommand());
String rootCommand = properties.getCommand().getCompletion().getRootCommand();
Assert.hasText(rootCommand, "'rootCommand' must be specified");
return new Completion(rootCommand);
}

@Bean
@ConditionalOnMissingBean(Version.Command.class)
@ConditionalOnProperty(prefix = "spring.shell.command.version", value = "enabled", havingValue = "true", matchIfMissing = true)
public Version version(SpringShellProperties properties, ObjectProvider<BuildProperties> buildProperties,
ObjectProvider<GitProperties> gitProperties, ObjectProvider<TemplateExecutor> templateExecutor) {
Version version = new Version(templateExecutor.getIfAvailable());
TemplateExecutor executor = templateExecutor.getIfAvailable();
Assert.notNull(executor, "'executor' must not be null");
Version version = new Version(executor);
VersionCommand versionProperties = properties.getCommand().getVersion();
version.setTemplate(versionProperties.getTemplate());
return version;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,17 @@
import java.nio.file.Paths;
import java.util.function.Function;

import org.jspecify.annotations.Nullable;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.shell.config.UserConfigPathProvider;
import org.springframework.util.StringUtils;

/**
* @author Piotr Olaszewski
*/
@AutoConfiguration
@EnableConfigurationProperties(SpringShellProperties.class)
public class UserConfigAutoConfiguration {
Expand All @@ -42,14 +46,15 @@ public UserConfigPathProvider userConfigPathProvider(SpringShellProperties sprin

static class LocationResolver {

private final static String XDG_CONFIG_HOME = "XDG_CONFIG_HOME";
private final static String APP_DATA = "APP_DATA";
private static final String XDG_CONFIG_HOME = "XDG_CONFIG_HOME";
private static final String APP_DATA = "APP_DATA";
private static final String USERCONFIG_PLACEHOLDER = "{userconfig}";
private Function<String, Path> pathProvider = (path) -> Paths.get(path);
private final String configDirEnv;
private final String configDirLocation;

LocationResolver(String configDirEnv, String configDirLocation) {
private final Function<String, Path> pathProvider = Paths::get;
private final @Nullable String configDirEnv;
private final @Nullable String configDirLocation;

LocationResolver(@Nullable String configDirEnv, @Nullable String configDirLocation) {
this.configDirEnv = configDirEnv;
this.configDirLocation = configDirLocation;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@NullMarked
package org.springframework.shell.boot.condition;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@NullMarked
package org.springframework.shell.boot;

import org.jspecify.annotations.NullMarked;
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
class StandardCommandsAutoConfigurationTests {

private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(StandardCommandsAutoConfiguration.class));
.withConfiguration(AutoConfigurations.of(StandardCommandsAutoConfiguration.class, ThemingAutoConfiguration.class));

@Test
void testCompletionCommand() {
Expand Down
Loading