From 7e8c5f5940ab66f3ae6fe57386a7ac33fcc4e9fc Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 1 Nov 2016 09:57:42 +0000 Subject: [PATCH] Silence CLI dependency resolution progress reporting when run with -q Closes gh-7247 --- .../command/run/SpringApplicationRunner.java | 7 +++++- .../cli/compiler/grape/AetherGrapeEngine.java | 22 ++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/SpringApplicationRunner.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/SpringApplicationRunner.java index 02be19ad7af..162fe15e1b7 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/SpringApplicationRunner.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/run/SpringApplicationRunner.java @@ -73,7 +73,9 @@ public class SpringApplicationRunner { this.compiler = new GroovyCompiler(configuration); int level = configuration.getLogLevel().intValue(); if (level <= Level.FINER.intValue()) { - System.setProperty("groovy.grape.report.downloads", "true"); + System.setProperty( + "org.springframework.boot.cli.compiler.grape.ProgressReporter", + "detail"); System.setProperty("trace", "true"); } else if (level <= Level.FINE.intValue()) { @@ -82,6 +84,9 @@ public class SpringApplicationRunner { else if (level == Level.OFF.intValue()) { System.setProperty("spring.main.banner-mode", "OFF"); System.setProperty("logging.level.ROOT", "OFF"); + System.setProperty( + "org.springframework.boot.cli.compiler.grape.ProgressReporter", + "none"); } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index 82e8e78fd14..c62d40f98da 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -93,10 +93,25 @@ public class AetherGrapeEngine implements GrapeEngine { } private ProgressReporter getProgressReporter(DefaultRepositorySystemSession session) { - if (Boolean.getBoolean("groovy.grape.report.downloads")) { + String progressReporter = 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); } - return new SummaryProgressReporter(session, System.out); + else if ("none".equals(progressReporter)) { + return new ProgressReporter() { + + @Override + public void finished() { + + } + + }; + } + else { + return new SummaryProgressReporter(session, System.out); + } } @Override @@ -340,4 +355,5 @@ public class AetherGrapeEngine implements GrapeEngine { throw new UnsupportedOperationException( "Grabbing an endorsed module is not supported"); } + }