我为Android应用设置的默认ant系统有两个不同的选项:发布和调试。我可以使用${build.is.packaging.debug}
来区分这两者。我可以通过执行ant release
或ant debug
一步构建这些内容。
我希望能够添加第三个选项: beta 。这样我可以为beta用户启用某些标志,我不希望普通用户看到这些标志,同时仍然省略我的调试代码。在ant构建系统中,我指定了一个新目标吗?
答案 0 :(得分:1)
如果您打开项目build.xml
,您会发现目标发布和调试。您应该创建一个类似名称 beta 的新广告,并在那里设置应用您的特定参数。
以下是简单的ant构建过程的示例:
<project name="j2me_library" default="build" basedir=".">
<property name="build.version" value="1.0.0" />
<property name="build.name" value="library-${build.version}" />
<property name="src" value="src" />
<property name="lib" value="lib" />
<property name="build" value="build" />
<property name="classes" value="${build}/classes" />
<property name="dist" value="${build}/dist" />
<!--
the "build" target is the default entry point of this script
-->
<target name="build" depends="package" />
<!--
the "clean" target will delete the build directory which contains lots of mess from the previous build
-->
<target name="clean">
<delete dir="${build}" />
</target>
<target name="prepare" depends="clean">
<mkdir dir="${classes}"/>
<mkdir dir="${dist}"/>
</target>
<!--
the "compile" target generates the .class files from the .java sources
-->
<target name="compile" depends="prepare">
<path id="lib.files">
<fileset dir="${lib}">
<include name="*.jar" />
</fileset>
</path>
<property name="lib.classpath" refid="lib.files" />
<javac srcdir="${src};"
destdir="${classes}"
includeantruntime="false"
classpath="${lib.classpath}"
bootclasspath="${lib.classpath}"
target="1.1"
source="1.2"
/>
</target>
<!--
the "package" target creates the jar file
-->
<target name="package" depends="compile">
<jar destfile="${dist}/${build.name}.jar" basedir="${classes}"/>
</target>
</project>