android - gradle如何执行一个ant构建文件

标签 android ant gradle build-process

我一直在努力将我的 custom_rules.xml 重建为 gradle 中的东西,但事实证明这非常困难。所以我的下一步是尝试将我在 gradle 中不能做的最后几件事导入为 build.xml。

然而,这似乎没有任何作用。当我尝试使用 ant.importBuild 'build.xml' 我的脚本没有反馈或回声。我通读了很多 gradles 文档,尤其是关于 ant 的文档,在我的一生中,我无法弄清楚导入构建后我应该做什么。脚本如何执行?

这是我的build.xml

<?xml version="1.0" encoding="UTF-8"?>
<project>
<target name="postPackage" >
<property name="config_path" location="${cert.dir}" />
<property name="out.pre.widevine.signed.file" location="release-pre-widevine-sign.apk" />
<property name="out.widevine.signed.file" location="release-widevine-signed.apk" />
<echo>sign with widevine certificate</echo>
<touch file="res/raw/wv.properties"/>
<copy file="${out.packaged.file}" tofile="${out.pre.widevine.signed.file}"/>
<java jar="apksigtool.jar" failonerror="true" fork="true">
    <arg value="${out.packaged.file}"/>
    <arg value="private_key.der" />
    <arg value="my.crt" />
</java>
<copy file="${out.packaged.file}" tofile="${out.widevine.signed.file}"/>
</target>
</project>

最佳答案

我能够通过在方法中使用以下代码 fragment 来完成此操作

    ant.importBuild 'build.xml'
    postPackage.doFirst{println("Im starting")}
    postPackage.execute()

关于android - gradle如何执行一个ant构建文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26043478/

相关文章:

android - 即使在使用命名空间 http ://schemas. android.com/apk/res-auto 之后,“找不到属性的资源标识符”错误

android - 如何管理指挥类的所有 Activity 转移

Gradle 项目命名约定

java - android库中的依赖项,但不存在

ant - 并行运行 JUnit 测试

android - 如何为 Android 开发设置 Vim?

java - 无法从 EditText 转换为 Button

java - 将 SVN 修订版注入(inject)变量

java - ANT + propertyregex 问题

java - adfm.jar 文件的用途是什么?如何将其从构建中排除?