仅使用 build.xml 插入构建目标?
我有一个 build.xml,如果我单独运行构建目标,它能够编译和优化 - “ant 编译”后跟“并优化”。
问题是,我想运行“ant release”,它通常会执行生成发布二进制文件所需的一切,但我需要将构建目标插入到链中 - 该目标称为“optimize”,并且它运行 proguard 优化/shrinker 在“dex”阶段构建字节码之前针对类文件。
模板文件 /opt/android-sdk-linux_x86/platforms/android-8/templates/android_rules.xml 包含以下规则,我可以修改为“depends=”compile,optimize””但我不想必须针对每个不同的 SDK 重新修改该文件(每次都使用新的 android_rules.xml 文件)。
<!-- Converts this project's .class files into .dex files -->
<target name="-dex" depends="compile">
<dex-helper />
</target>
是否有其他方法可以修改模板 xml 并将所有编译规则放入 build.xml 中?
I have a build.xml which is capable of compiling and optimizing if I run the build targets individually - "ant compile" followed by "and optimize".
The problem is, that I want to run "ant release" which would normally do Everything necessary to produce the release binary, but I need to insert a build target to the chain - the target is called "optimize" and it runs a proguard optimize/shrinker against the class files just before the "dex" stage builds the byte code.
The template file /opt/android-sdk-linux_x86/platforms/android-8/templates/android_rules.xml contains the following rule, which I could modify to say "depends="compile,optimize" " But I don't want to have to re-modify the file for every different SDK that comes out (with a new android_rules.xml file each time).
<!-- Converts this project's .class files into .dex files -->
<target name="-dex" depends="compile">
<dex-helper />
</target>
Is there an alternative to modifying the template xml and instead putting all compile rules into the build.xml?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么不在模板
build.xml
文件中使用编译后挂钩?它写道:鉴于它明确要求修改,我认为跨 sdk 版本将支持它。
要查看为您的项目自动生成的完整
build.xml
文件,您可能需要运行android update project
。Why not use the post-compile hook in the template
build.xml
file? It reads:Given that it's there explicitly asking for modification, I would think that it would be supported across sdk versions.
To see the full auto-generated
build.xml
file for your project you may need to runandroid update project
.以防万一您错过了:
从 SDK Tools Rev 8 开始,内置了 Proguard 支持。您只需将该行添加
到 default.properties(当然还有一个 proguard.cfg 文件,您可以在其中设置混淆规则) )
您不需要添加任何其他目标。
(无论如何,Windows 版本都是如此,我想 Linux 也是如此。“rules”xml 现在称为 main_rules.xml)
Just in case you missed it:
As of SDK Tools Rev 8, Proguard support is built in. You just need to add the line
to your default.properties (and have a proguard.cfg file of course, where you set up your obfuscation rules)
You don't need to add any other targets.
(This is true in the Windows version anyway, I imagine it's the same for Linux. The 'rules' xml is now called main_rules.xml)