W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
有許多方法可以設定 Ant 屬性,可以通過Ant任務使用屬性.您可以直接在AntBuilder的實例設置屬性。Ant的屬性也可以作為一個可改變的Map.也可以使用Ant的任務屬性,如下例所示:
例16.13.設置Ant屬性
build.gradle
ant.buildDir = buildDir
ant.properties.buildDir = buildDir
ant.properties['buildDir'] = buildDir
ant.property(name: 'buildDir', location: buildDir)
build.xml
<echo>buildDir = ${buildDir}</echo>
許多任務會在執(zhí)行時設置屬性.下面有幾種方法來獲取屬性值,可以直接從AntBuilder實例獲得屬性,如下所示,ant的屬性仍然是作為一個map:
例16.14.獲取Ant屬性
build.xml
<property name="antProp" value="a property defined in an Ant build"/>
build.gradle
println ant.antProp
println ant.properties.antProp
println ant.properties['antProp']
設置一個ant引用的方法:
例16.15.設置一個Ant引用
build.gradle
ant.path(id: 'classpath', location: 'libs')
ant.references.classpath = ant.path(location: 'libs')
ant.references['classpath'] = ant.path(location: 'libs')
build.xml
<path refid="classpath"/>
獲取Ant引用的方法:
例16.16.獲取一個Ant引用
build.xml
<path id="antPath" location="libs"/>
build.gradle
println ant.references.antPath
println ant.references['antPath']
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: