Gabriel
Gabriel

Reputation: 792

Creating ant build.xml files for each project in workspace

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!

Upvotes: 1

Views: 2666

Answers (3)

baroni
baroni

Reputation: 176

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

Upvotes: 0

Gabriel
Gabriel

Reputation: 792

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!

Upvotes: 0

Lolo
Lolo

Reputation: 4367

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>

Upvotes: 1

Related Questions