ant-скрипты для сборки apk-файла и загрузки его в эмулятор? - PullRequest
1 голос
/ 19 июля 2010

Я пытаюсь создать сценарий build.xml, который очищает, собирает и создает файл apk созданного мною тестового проекта Android для Android.

шаги, которые я хочу выполнить в своем файле сборки:это:

clean

build

создать файл apk

Подписать файл apk

запустить эмулятор

установить apkfile

run instrumentalTest

Сохранить тесты в отчете HTML Junit

Кто-нибудь знает, как этого добиться?до сих пор мой файл сборки выглядит следующим образом: ..

<!-- WARNING: Eclipse auto-generated file.
              Any modifications will be overwritten.
              To include a user specific buildfile here, simply 

create one in the same
              directory with the processing instruction <?

eclipse.ant.import?>
              as the first entry and export the buildfile again. 

-->
<project basedir="." default="build" name="Unity Agent SDK Test">
 <property environment="env" />
 <property name="junit.output.dir" value="junit" />
 <property name="debuglevel" value="source,lines,vars" />
 <property name="target" value="1.6" />
 <property name="source" value="1.6" />
 <property file="build.properties" />
 <path id="android1.6.userclasspath">
  <pathelement location="lib/android.jar" />
 </path>
 <path id="Junit.userclasspath">
  <pathelement location="lib/junit-4.8.2" />
  <pathelement location="lib/org.hamcrest.core_1.1.0.v20090501071000.jar" />
 </path>
 <path id="Unity Agent SDK Test.classpath">
  <pathelement location="bin" />
  <pathelement location="lib/fb_connect-android-api.jar" />
  <pathelement location="lib/signpost-commonshttp4-1.2.jar" />
  <pathelement location="lib/signpost-core-1.2.jar" />
  <pathelement location="lib/UnityAgentSDK.jar" />
  <path refid="android1.6.userclasspath" />
  <path refid="Junit.userclasspath" />
 </path>

 <path id="android.antlibs">
  <pathelement path="${android-sdk-path}/tools/lib/anttasks.jar" />
  <pathelement path="${android-sdk-path}/tools/lib/sdklib.jar" />
  <pathelement path="${android-sdk-path}/tools/lib/androidprefs.jar" />
  <pathelement path="${android-sdk-path}/tools/lib/apkbuilder.jar" />
  <pathelement path="${android-sdk-path}/tools/lib/jarutils.jar" />
 </path>

 <path id="run.Unity Agent SDK Test (1).classpath">
  <path refid="Unity Agent SDK Test.classpath" />
 </path>
 <path id="run.Unity Agent SDK Test (1).bootclasspath" />
 <target name="init">
  <echo message="Initialize project" />
  <mkdir dir="bin" />
  <copy includeemptydirs="false" todir="bin">
   <fileset dir="src">
    <exclude name="**/*.launch" />
    <exclude name="**/*.java" />
   </fileset>
  </copy>
  <copy includeemptydirs="false" todir="bin">
   <fileset dir="gen">
    <exclude name="**/*.launch" />
    <exclude name="**/*.java" />
   </fileset>
  </copy>
 </target>

 <target name="clean">
  <echo message="Cleaning project" />
  <delete dir="bin" />
 </target>
 <target depends="clean" name="cleanall" />
 <target depends="build-subprojects,build-project" name="build" />
 <target name="build-subprojects" />
 <target depends="init" name="build-project">
  <echo message="${ant.project.name}: ${ant.file}" />
  <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
   <src path="src" />
   <classpath refid="Unity Agent SDK Test.classpath" />
  </javac>
  <javac debug="true" debuglevel="${debuglevel}" destdir="bin" source="${source}" target="${target}">
   <src path="gen" />
   <classpath refid="Unity Agent SDK Test.classpath" />
  </javac>
 </target>
 <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects" />
 <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
  <copy todir="${ant.library.dir}">
   <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar" />
  </copy>
  <unzip dest="${ant.library.dir}">
   <patternset includes="jdtCompilerAdapter.jar" />
   <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar" />
  </unzip>
 </target>
 <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
  <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
  <antcall target="build" />
 </target>
 <target name="Unity Agent SDK Test ">
  <mkdir dir="${junit.output.dir}" />
  <echo message="making directory" />
  <junit fork="yes" printsummary="yes">
   <formatter type="xml" />
   <test name="com.kc.AllTests" todir="${junit.output.dir}" />

   <!--
   <test name="com.kc.AllTests" todir="${junit.output.dir}" />

             <test name="com.kc.unity.agent.util.ActivityOneTestcase" todir="${junit.output.dir}" />
   <test name="com.kc.unity.agent.util.FaceBookRestManagerTestCase" todir="${junit.output.dir}" />
   <test name="com.kc.unity.agent.util.OAuthManagerTestCase" todir="${junit.output.dir}" /> 
-->

   <classpath refid="Unity Agent SDK Test.classpath" />

   <bootclasspath>
    <path refid="run.Unity Agent SDK Test (1).bootclasspath" />
   </bootclasspath>
  </junit>
  <echo message="junit finished" />
 </target>
 <target name="junitreport">
  <junitreport todir="${junit.output.dir}">
   <fileset dir="${junit.output.dir}">
    <include name="TEST-*.xml" />
   </fileset>
   <report format="frames" todir="${junit.output.dir}" />
  </junitreport>
 </target>

 <!--
 Build it and set it up for android
 -->
 <echo message="Build it and set it up for android" />
  <echo message="${android-sdk-path}" />
  <target name="push_tests_to_device"  depends="build">
   <exec executable="${android-sdk-path}/tools/adb.exe">
    <arg value="install"/>
    <arg value="${test_apk_path}"/>
   </exec>
  </target>

  <target name="run_tests"  depends="push_tests_to_device">
   <exec executable="${android-sdk-path}/tools/adb.exe">
    <arg value="shell"/>
    <arg value="am"/>
    <arg value="instrument"/>
    <arg value="-w"/>
    <arg value="com.kc.tests/android.test.InstrumentationTestRunner"/>
   </exec>
  </target>

</project>

Я могу отлично очистить и собрать проект, но не знаю, как создать файл apk, подписать его, запустить instrumentalTest и создать отчеты junit в формате html..

заранее спасибо.это первый раз, когда я погрузился в это.я попытался автоматически сгенерировать build.xml, используя eclipse> project> export> ant build script, и он не добавил сборку apk, запустил instrumenatlTest и запустил в нем эмулятор.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...