Suppress "resolving dependencies" when --quiet

Update Spring CLI so that the "resolving dependencies" message is
suppressed when `run --quiet` is used.

Fixes gh-8946
pull/7954/merge
Phillip Webb 8 years ago
parent cde5793240
commit bddc190848

@ -92,4 +92,9 @@ public class OptionSetGroovyCompilerConfiguration implements GroovyCompilerConfi
return this.repositoryConfiguration;
}
@Override
public boolean isQuiet() {
return false;
}
}

@ -140,7 +140,7 @@ public class RunCommand extends OptionParsingCommand {
@Override
public Level getLogLevel() {
if (getOptions().has(RunOptionHandler.this.quietOption)) {
if (isQuiet()) {
return Level.OFF;
}
if (getOptions().has(RunOptionHandler.this.verboseOption)) {
@ -149,6 +149,11 @@ public class RunCommand extends OptionParsingCommand {
return Level.INFO;
}
@Override
public boolean isQuiet() {
return getOptions().has(RunOptionHandler.this.quietOption);
}
}
}

@ -95,7 +95,8 @@ public class GroovyCompiler {
new SpringBootDependenciesDependencyManagement());
AetherGrapeEngine grapeEngine = AetherGrapeEngineFactory.create(this.loader,
configuration.getRepositoryConfiguration(), resolutionContext);
configuration.getRepositoryConfiguration(), resolutionContext,
configuration.isQuiet());
GrapeEngineInstaller.install(grapeEngine);

@ -71,4 +71,10 @@ public interface GroovyCompilerConfiguration {
*/
List<RepositoryConfiguration> getRepositoryConfiguration();
/**
* Returns if running in quiet mode.
* @return {@code true} if running in quiet mode
*/
boolean isQuiet();
}

@ -77,7 +77,7 @@ public class AetherGrapeEngine implements GrapeEngine {
RepositorySystem repositorySystem,
DefaultRepositorySystemSession repositorySystemSession,
List<RemoteRepository> remoteRepositories,
DependencyResolutionContext resolutionContext) {
DependencyResolutionContext resolutionContext, boolean quiet) {
this.classLoader = classLoader;
this.repositorySystem = repositorySystem;
this.session = repositorySystemSession;
@ -89,12 +89,14 @@ public class AetherGrapeEngine implements GrapeEngine {
for (RemoteRepository repository : remotes) {
addRepository(repository);
}
this.progressReporter = getProgressReporter(this.session);
this.progressReporter = getProgressReporter(this.session, quiet);
}
private ProgressReporter getProgressReporter(DefaultRepositorySystemSession session) {
String progressReporter = System.getProperty(
"org.springframework.boot.cli.compiler.grape.ProgressReporter");
private ProgressReporter getProgressReporter(DefaultRepositorySystemSession session,
boolean quiet) {
String progressReporter = (quiet ? "none"
: System.getProperty(
"org.springframework.boot.cli.compiler.grape.ProgressReporter"));
if ("detail".equals(progressReporter)
|| Boolean.getBoolean("groovy.grape.report.downloads")) {
return new DetailedProgressReporter(session, System.out);

@ -44,27 +44,21 @@ public abstract class AetherGrapeEngineFactory {
public static AetherGrapeEngine create(GroovyClassLoader classLoader,
List<RepositoryConfiguration> repositoryConfigurations,
DependencyResolutionContext dependencyResolutionContext) {
DependencyResolutionContext dependencyResolutionContext, boolean quiet) {
RepositorySystem repositorySystem = createServiceLocator()
.getService(RepositorySystem.class);
DefaultRepositorySystemSession repositorySystemSession = MavenRepositorySystemUtils
.newSession();
ServiceLoader<RepositorySystemSessionAutoConfiguration> autoConfigurations = ServiceLoader
.load(RepositorySystemSessionAutoConfiguration.class);
for (RepositorySystemSessionAutoConfiguration autoConfiguration : autoConfigurations) {
autoConfiguration.apply(repositorySystemSession, repositorySystem);
}
new DefaultRepositorySystemSessionAutoConfiguration()
.apply(repositorySystemSession, repositorySystem);
return new AetherGrapeEngine(classLoader, repositorySystem,
repositorySystemSession, createRepositories(repositoryConfigurations),
dependencyResolutionContext);
dependencyResolutionContext, quiet);
}
private static ServiceLocator createServiceLocator() {

@ -81,6 +81,11 @@ public class GroovyGrabDependencyResolverTests {
return new String[] { "." };
}
@Override
public boolean isQuiet() {
return false;
}
};
this.resolver = new GroovyGrabDependencyResolver(configuration);
}

@ -59,7 +59,7 @@ public class AetherGrapeEngineTests {
dependencyResolutionContext.addDependencyManagement(
new SpringBootDependenciesDependencyManagement());
return AetherGrapeEngineFactory.create(this.groovyClassLoader,
repositoryConfigurations, dependencyResolutionContext);
repositoryConfigurations, dependencyResolutionContext, false);
}
@Test

Loading…
Cancel
Save