W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
Ant 任務是 Gradle 的一等公民. Gradle 通過 Groovy 出色的集成了 Ant 任務. Groovy 自帶了一個 AntBuilder. 相比于從一個 build.xml 文件中使用 Ant 任務, 在 Gradle 里使用 Ant 任務更為方便和強大. 從下面的例子中, 你可以學習如何執(zhí)行 Ant 任務以及如何訪問 ant 屬性:
例子 6.13. 使用 AntBuilder 來執(zhí)行 ant.loadfile 任務
build.gradle
task loadfile << {
def files = file('../antLoadfileResources').listFiles().sort()
files.each { File file ->
if (file.isFile()) {
ant.loadfile(srcFile: file, property: file.name)
println " *** $file.name ***"
println "${ant.properties[file.name]}"
}
}
}
gradle -q loadfile 命令的輸出
> gradle -q loadfile
*** agile.manifesto.txt ***
Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan
*** gradle.manifesto.txt ***
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: