cop*_*lii 8 java ant configuration android build
我有一个ant脚本可以执行它需要做的事情,但我需要根据我是在运行发布还是调试来设置一些属性值.我该怎么做呢?
如果它有所不同,我的ant脚本在执行android构建之前运行一些自定义实用程序任务.
回答我自己的问题:
属性查找是" build.mode.release "和" build.mode.debug ",但有一个警告 ......如果你的清单有可调试="真",则系统将恢复到调试模式有轻微的"短缺'(IMO)
注意:这仅适用于Android版本
"警告"的原因实际上记录在Android main_rules.xml项目($ANDROID_SDK_ROOT/tools/ant/main_rules.xml)中:
<target name="-set-release-mode">
<!-- release mode is only valid if the manifest does not explicitly
set debuggable to true. default is false.
We actually store build.packaging.debug, not build.release -->
<xpath input="AndroidManifest.xml" expression="/manifest/application/@android:debuggable"
output="build.packaging.debug" default="false"/>
...
</target>
Run Code Online (Sandbox Code Playgroud)
所以你要检查的是build.mode.debug(通过执行ant debug),build.mode.release(当@debuggable=false执行时ant release),并最终满足你的警告:( build.packaging.debug何时@debuggable=true执行ant release)
这是一个自动预编译的示例:
<target name="-my-debug-precompile" if="build.mode.debug">
<!-- This is executed for any "debug" build ("ant debug") -->
</target>
<target name="-my-release-precompile" unless="build.mode.debug">
<!-- This is executed for any non-"debug" build (e.g., "ant release",
regardless of the @debuggable attribute in AndroidManifest.xml) -->
</target>
<!-- This is called automatically by Android's ant tasks, and delegates the
task to one of the above two targets: -->
<target name="-pre-compile" depends="-my-debug-precompile,-my-release-precompile" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6227 次 |
| 最近记录: |