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; return this.repositoryConfiguration;
} }
@Override
public boolean isQuiet() {
return false;
}
} }

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

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

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

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

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

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

Loading…
Cancel
Save