Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gradle run で入力ができない #1

Closed
masakura opened this issue Apr 9, 2017 · 1 comment
Closed

gradle run で入力ができない #1

masakura opened this issue Apr 9, 2017 · 1 comment

Comments

@masakura
Copy link
Owner

masakura commented Apr 9, 2017

gradle run で、検索キーワードの入力ができず、そのまま実行されてしまう。

:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE    
:run
GitHub Repository の検索キーワードを入力してください:
NARKOZ/gitlab => https://github.com/NARKOZ/gitlab
gitlabhq/gitlabhq => https://github.com/gitlabhq/gitlabhq

... snip

本当は、検索キーワードを入力してください: で入力待ちになるはずだけど、何も入力しないまま流れてしまう。

https://github.com/masakura/decorator-sample/blob/master/src/main/java/labo/github/Ui.java#L20-L26

    public String getInput() {
        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(is);

        System.out.println("GitHub Repository の検索キーワードを入力してください: ");

        try {
            return br.readLine();

        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
@masakura
Copy link
Owner Author

run できない問題は
build.gradleに

run {
   standardInput = System.in
}

を追加すると行けます。標準のgradleコマンドではinputに対応していないみたいですね。
またこのまま./graldlew run するとbuildの状況まで出力されてしまうのでそれを防ぐために -q オプションで出力されないようにする必要があります。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant