如何使用Ant来自动重命名输出apk文件? [英] How to use Ant to auto renaming output apk file?

查看:185
本文介绍了如何使用Ant来自动重命名输出apk文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用Ant玩,做一些品牌汽车的工作。我修改默认的build.xml并设置自己的目标。我希望要问的是,有没有在Ant脚本的一种方式,可以自动重命名的apk文件只是建立在一定的名字吗?

I'm currently playing with Ant to do some auto branding work. I modified default build.xml and setup my own target. What I hope to ask is that is there a way in Ant Script that could automatic renaming the apk file just build with the certain name?

目前,我有这个Ant目标设定在我的build.xml:

I currently has this Ant target setup in my build.xml:

<target name="release-brandA"
            depends="default, -set-release-mode, -release-obfuscation-check, -package, -post-package, -release-prompt-for-password, -release-nosign, -release-sign, -post-build"
            description="Builds the application in release mode for brandA.">
    <delete dir="${res}" />
    <copydir dest="${res}" src="${branding}/brandA" forceoverwrite="ture" />
    <replaceregexp flags="g" byline="false">
        <regexp pattern="import com.arthur.android(.*).R;"/>
        <substitution expression="import com.arthur.android.brandA.R;"/>
        <fileset dir="src" includes="**/*.java" />
    </replaceregexp>
    <replaceregexp flags="g" byline="false">
        <regexp pattern="package=&quot;com.arthur.android(.*)&quot;" />
        <substitution expression="package=&quot;com.arthur.android.brandA&quot;" />
        <fileset dir="" includes="AndroidManifest.xml" />
    </replaceregexp>
</target>

有没有我可以添加一些更多的任务,让输出文件只是像brandA.apk的方式?

Is there a way that I could add some more task, to let the output file just be like brandA.apk?

感谢您!

推荐答案

最后的apk文件名实际上是由房地产out.final.file定义

The final apk filename is actually defined by the property 'out.final.file'

所以,你可以创建一个新任务,设置该属性:

So you could create a new Task that sets this property:

<target name="-set-out-final-file">
    <property name="out.final.file" location="${out.absolute.dir}/brandA.apk" />
</target>

最后,你只需要调用 -set出决赛文件目标调用调试或释放前的目标。

Finally, you just need to invoke the -set-out-final-file target before calling the debug or release targets.

使用您的公布,品牌A 任务,它会成为这样的:

Using your release-brandA task, it would become this:

<target name="release-brandA"
        depends="default, -set-out-final-file, -set-release-mode, -release-obfuscation-check...

这篇关于如何使用Ant来自动重命名输出apk文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆