codecamp

Gradle Ant 的属性与引用

Ant的属性与引用

有许多方法可以设定 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>

许多任务会在执行时设置属性.下面有几种方法来获取属性值,可以直接从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']
Gradle 在构建中使用自定义 Ant 任务
Gradle Logging
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

Gradle 使用 Ant 插件

Gradle 使用 Ant 任务和 Ant 类型的构建

Gradle 导入一个 Ant 构建

Gradle Ant 的属性与引用

Gradle API

Gradle Gradle Plugins

Gradle 使用构建脚本块应用插件

Gradle 查找社区插件

Gradle 更多关于插件

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }