This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tasks.addRule("Pattern: sample<ID>") { String taskName -> | |
if (taskName.startsWith("sample")) { | |
task(taskName) << { | |
println taskName - 'sample' | |
} | |
} | |
} |
addRuleの第1引数に指定したdescriptionは、tasksタスク実行時にRulesのセクションに表示される。第2引数のクロージャでは、特定の条件にマッチするタスク名に対応するタスクを定義する。この例では、‘sample’で始まるタスク名をもつタスクを定義している。
tasksタスクを実行した結果は、以下の通り。
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
関連リンク
- Gradle本家ユーザガイド
0 件のコメント:
コメントを投稿