2

我为我的 Android 应用程序设置的默认 ant 系统有两个不同的选项:发布调试。我可以使用${build.is.packaging.debug}. ant release我可以通过执行或一步构建这些ant debug

我希望能够添加第三个选项:beta。通过这种方式,我可以为 beta 用户启用某些我不希望普通用户看到的标志,同时仍然忽略我的调试代码。我在 ant 构建系统的哪个位置指定新目标?

4

1 回答 1

1

如果你打开你的项目build.xml,你会发现目标releasedebug。您应该创建一个类似名称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>
于 2012-08-16T08:09:49.240 回答