【问题标题】:Android ant builds other than release and debug除了发布和调试之外的 Android ant 构建
【发布时间】:2012-08-15 22:49:27
【问题描述】:

我为我的 Android 应用设置的默认 ant 系统有两个不同的选项:releasedebug。我可以使用${build.is.packaging.debug} 区分两者。我可以通过ant releaseant debug 一步构建这些。

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

【问题讨论】:

    标签: android ant android-build


    【解决方案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>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-28
      • 2011-02-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-01
      • 1970-01-01
      相关资源
      最近更新 更多