我使用Ant构建我的Android应用程序。我希望能够做到这一点:
ant debug android-market; //build the debug version for android-market;
ant debug motorola-market; //Builds debug version for motorola-market;
ant release android-market; //etc.有没有办法从我的自定义ant调试/发布任务中检测"android-market“参数?
我不喜欢使用Dparam=value,因为它看起来不那么整洁。
发布于 2011-03-26 03:24:43
此语法用于一次调用多个目标。所以你也许可以使用
ant android-market debug并让android-market目标设置一个在debug目标中使用的属性,以标识要构建的版本:
<project basedir="." default="debug">
<target name="android-market">
<property name="market" value="android"/>
</target>
<target name="debug">
<echo message="debugging for the following market : ${market}"/>
</target>
</project>
> ant android-market debug
> android-market:
> debug:
> [echo] debugging for the following market : android发布于 2011-03-26 03:35:33
我不喜欢使用-Dparam=value,因为那样看起来不太干净。
我认为你应该克服你的偏好。但是添加一个“help”目标来描述其他目标所接受的参数。
发布于 2013-01-12 04:01:27
JB的回答完全有效,但我想找到一种默认的方法。我在这里找到了一个叫Mike Schilling的人的答案:http://www.velocityreviews.com/forums/t137033-is-it-possible-to-alter-ant-properties-after-theyve-been-initialized.html
所以我最终得到了像这样的东西:
<project basedir="." default="debug">
<target name="set-defaults">
<property name="market" value="android"/>
</target>
<target name="motorola-market">
<property name="market" value="motorola/>
</target>
<target name="debug" depends="set-defaults">
<echo message="debugging for the following market : ${market}"/>
</target>
</project>所以你可以为安卓系统做ant debug,或者为摩托罗拉做ant motorola-market debug。
https://stackoverflow.com/questions/5437067
复制相似问题