diff options
author | Julien HENRY <julien.henry@sonarsource.com> | 2015-09-28 18:06:36 +0200 |
---|---|---|
committer | Julien HENRY <julien.henry@sonarsource.com> | 2015-09-28 18:06:36 +0200 |
commit | fae72d56be0414e34849b36f7b345ec23c87515b (patch) | |
tree | 98b5b9f6c7511dfc9fce3759c5c4cb4de3a15b06 /sonar-runner-cli/src/main/java/org/sonar | |
parent | 8865c467f7686cc52938b361fcd738a48cab654b (diff) | |
download | sonar-scanner-cli-fae72d56be0414e34849b36f7b345ec23c87515b.tar.gz sonar-scanner-cli-fae72d56be0414e34849b36f7b345ec23c87515b.zip |
SONARUNNER-137 Don't prevent aborting process in non interactive mode
Diffstat (limited to 'sonar-runner-cli/src/main/java/org/sonar')
3 files changed, 12 insertions, 10 deletions
diff --git a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java index d0a350e..3b627df 100644 --- a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java +++ b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Cli.java @@ -29,11 +29,11 @@ class Cli { private boolean displayStackTrace = false; private boolean interactive = false; private final Properties props = new Properties(); - private final Shutdown shutdown; + private final Exit exit; private final Logs logger; - public Cli(Shutdown shutdown, Logs logger) { - this.shutdown = shutdown; + public Cli(Exit exit, Logs logger) { + this.exit = exit; this.logger = logger; } @@ -147,6 +147,6 @@ class Cli { logger.info(" -v,--version Display version information"); logger.info(" -X,--debug Produce execution debug output"); logger.info(" -i,--interactive Run interactively"); - shutdown.exit(Exit.SUCCESS); + exit.exit(Exit.SUCCESS); } } diff --git a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java index 71488b3..457380b 100644 --- a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java +++ b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Main.java @@ -58,10 +58,10 @@ public class Main { public static void main(String[] args) { Exit exit = new Exit(); - Shutdown shutdown = new Shutdown(exit); Logs logs = new Logs(); - Cli cli = new Cli(shutdown, logs).parse(args); + Cli cli = new Cli(exit, logs).parse(args); cli.verify(); + Shutdown shutdown = new Shutdown(exit, cli.isInteractive()); Main main = new Main(shutdown, cli, new Conf(cli, logs), new RunnerFactory(logs), logs); main.execute(); } diff --git a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Shutdown.java b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Shutdown.java index 3c52bc5..7da4f93 100644 --- a/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Shutdown.java +++ b/sonar-runner-cli/src/main/java/org/sonar/runner/cli/Shutdown.java @@ -31,14 +31,16 @@ class Shutdown { private Object lock = new Object(); private Exit exit; - Shutdown(Exit exit) { - this(exit, DEFAULT_MAX_WAIT); + Shutdown(Exit exit, boolean isInteractive) { + this(exit, isInteractive, DEFAULT_MAX_WAIT); } - Shutdown(Exit exit, long maxWait) { + Shutdown(Exit exit, boolean isInteractive, long maxWait) { this.maxWait = maxWait; this.exit = exit; - Runtime.getRuntime().addShutdownHook(hook); + if (isInteractive) { + Runtime.getRuntime().addShutdownHook(hook); + } } void exit(int status) { |