標準出力をByteArrayOutputStreamに割り当て(13行目)、コマンド実行後にそのByteArrayOutputStreamから文字列を取得している(23行目)。
上記のタスクを実行した結果は以下の通り。
当たり前だが、コマンド実行時に出力される文字列は、コマンドの実行後でないと取得できない。$ gradle -q execCommandLine doFirst doLast hello
当たり前だが、コマンド実行時に出力される文字列は、コマンドの実行後でないと取得できない。$ gradle -q execCommandLine doFirst doLast hello
Task Ruleとして定義したタスクを実行した結果は、以下の通り。$ gradle tasks :tasks ------------------------------------------------------------ All tasks runnable from root project ------------------------------------------------------------ Help tasks ---------- dependencies - Displays all dependencies declared in root project 'aaa'. dependencyInsight - Displays the insight into a specific dependency in root pr ect 'aaa'. help - Displays a help message projects - Displays the sub-projects of root project 'aaa'. properties - Displays the properties of root project 'aaa'. tasks - Displays the tasks runnable from root project 'aaa' (some of the displ ed tasks may belong to subprojects). Rules ----- Pattern: sample<ID> To see all tasks and more detail, run with --all.
$ gradle sample1 sample2 :sample1 1 :sample2 2