如何在运行Gradle JavaExec任务以捕获用户输入时禁止“构建x%”消息?

时间:2016-10-17 20:24:46

标签: gradle gradlew

运行Gradle JavaExec任务以捕获用户输入时是否可以禁止'Building x%'消息?

我有一个自定义的JavaExec任务,如:

task runApp(type: JavaExec) {
    classpath = sourceSets.main.runtimeClasspath
    main = "RSBot"
    standardInput = System.in
}

它使用standardInput来捕获用户输入。 捕获用户输入,直到退出该过程。

JavaExec任务在底部继续显示> Building 87% > :rivescript-samples-rsbot:runApp消息的问题非常烦人,因为用户需要在那里输入输入。

请看下面的例子。

$ ./gradlew :rivescript-samples-rsbot:runApp
:rivescript-core:compileJava UP-TO-DATE
:rivescript-core:processResources UP-TO-DATE
:rivescript-core:classes UP-TO-DATE
:rivescript-core:jar UP-TO-DATE
:rivescript-samples-rsbot:compileJava UP-TO-DATE
:rivescript-samples-rsbot:processResources UP-TO-DATE
:rivescript-samples-rsbot:classes UP-TO-DATE
:rivescript-samples-rsbot:runApp
      .   .       
     .:...::      RiveScript Java // RSBot
    .::   ::.     Version: 0.6.0
 ..:;;. ' .;;:..  
    .  '''  .     Type '/quit' to quit.
     :;,:,;:      Type '/help' for more options.
     :     :      

:: Creating RS Object
:: Loading replies
You> 
> BuiBot> How do you do. Please state your problem.   
You> 
> BuiBot> Please go on.   pt-samples-rsbot:runApphelp
You> 
> BuiBot> You're now playing the game. Type "help" for help.

You are in the lobby of a NASA launch base on Earth. There is an elevator to the north.   
You> 
> Building 87% > :rivescript-samples-rsbot:runApp

1 个答案:

答案 0 :(得分:2)

正如Haki先生向我指出的那样,--console plain命令行选项可以解决问题。

./gradlew :rivescript-samples-rsbot:runApp --console plain