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