当前位置:K88软件开发文章中心编程工具Gradle → 文章内容

Gradle 从 Gradle 中调用 Ant

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-24 10:31:29

出结果 > gradle hello:hello[ant:echo] Hello, from AntHello, from GradleBUILD SUCCESSFULTotal time: 1 secs 它也可以用于一个依赖于 Gradle 任务的 Ant 目标:依赖于 Gradle 任务的 Ant 目标build.gradle ant.importBuild 'build.xml'task intro << { println 'Hello, from Gradle'}build.xml<project> <target name="hello" depends="intro"> <echo>Hello, from Ant</echo> </target></project> gradle hello 的输出结果 > gradle hello:introHello, from Gradle:hello[ant:echo] Hello, from AntBUILD SUCCESSFULTotal time: 1 secs Ant 属性和引用有几种方法来设置 Ant 属性,以便使该属性被 Ant 任务使用。你可以直接在 AntBuilder 实例上设置属性。Ant 属性也可以从一个你可以修改的 Map 中获得。您还可以使用 Ant property 任务。下面是一些如何做到这一点的例子。Ant 属性设置build.gradle ant.buildDir = buildDirant.properties.buildDir = buildDirant.properties['buildDir'] = buildDirant.property(name: 'buildDir', location: buildDir)build.xml<echo>buildDir = ${buildDir}</echo> 许多 Ant 任务在执行时会设置一些属性。有几种方法来获取这些属性值。你可以直接从AntBuilder 实例获得属性。Ant 属性也可作为一个 Map。下面是一些例子。获取 Ant 属性build.xml <property name="antProp" value="a property defined in an Ant build"/>build.gradleprintln ant.antPropprintln ant.properties.antPropprintln ant.properties['antProp'] 有几种方法可以设置 Ant 引用: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 引用:获取 Ant 引用build.xml <path id="antPath" location="libs"/>build.gradleprintln ant.references.antPathprintln ant.references['antPath']

上一页  [1] [2] 


Gradle 从 Gradle 中调用 Ant