1
votes

How can I create an ANT file for multiple projects under the same workspace in Eclipse?

Thought about using Jenkins, but Jenkins creates a single build.xml file using the Ant Emulator Plugin, within each project and does not give me the possibility to insert my keystore parameters directly at build time.

The idea is that ultimately I want all my projects in my workspace signed using an automated tool.

Thank you!

3
I would recommend moving on to Gradle for Android, as support for Ant is going away. - CommonsWare
Thanks! But the only solution I can currently change is Jenkins, because the client is not willing to move away from eclipse. - Gabriel
Is my answer to this any use?stackoverflow.com/questions/9932498/… - NickT
A Gradle build script can be created that sticks with the classic project structure and allows for Eclipse to still build it. - CommonsWare

3 Answers

1
votes

In Eclipse, in the Package Explorer view, select your projects, then right-click ==> Export, select "General > Ant Buildfiles". In the next dialog, check or uncheck your options, then click "Finish" and a build.xml file is generated for each selected project.

Then all you need is a build.xml that will invoke the Ant build for all the projects, something looking like this:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project basedir="." default="build-all" name="all-projects">
  <target description="Build all projects" name="build-all">
    <ant antfile="build.xml" target="build-project" dir="./MyProject1" inheritAll="false"/>
    <ant antfile="build.xml" target="build-project" dir="./MyProject2" inheritAll="false"/>
    ...
    <ant antfile="build.xml" target="build-project" dir="./MyProjectN" inheritAll="false"/>
  </target>
</project>
0
votes

I have found the answer:

I have made a workspace general build.xml file. This file is built using Jenkins and Powershell Plugin and it looks like this:

<?xml version="1.0"?>
<project name="MainActivity">
    <property name="key.store" value="path_to_keystore_file" />
    <property name="key.alias" value="ssss" />
    <property name="key.store.password" value="xxx" />
    <property name="key.alias.password" value="xxx" />
    <ant dir="proj1">
        <target name="clean" />
        <target name="release" />
    </ant>
    <ant dir="proj2">
        <target name="clean" />
        <target name="release" />
    </ant>
    <ant dir="proj3">
        <target name="clean" />
        <target name="release" />
    </ant>
    <ant dir="proj4">
        <target name="clean" />
        <target name="release" />
    </ant>
</project>

After that I have generated Project specific build.xml files using Jenkins Android Emulator Plugin and as a final build step I have used Invoke Ant plugin with no parameters, which by default calls workspace/build.xml

My Jenkins build signs my Apk's accordingly and everything is fine. Thank you for your support!

0
votes
 android -v update project -n PROJECTNAME -p $WORKSPACE/project/path Android -t android-XX --subprojects