This week I converted async-msgcomp to use ant for building rather than the internal Eclipse builders because it was the only way I could figure out to get jar files automatically built. After some trial an error I came up with common-build.xml which are common tasks for all sub-project and resides at the root of my build tree. I also created android-build.xml which is in the android sub-directory and is the common Ant tasks for Android. Then within each sub-project is a build.xml, for instance java/debug/build.xml and android/debug/build.xml as well as a global build.xml file in my root. For full disclosure; common-build.xml was based on the build.xml file emitted by:
File -> Export -> General -> Ant Buildfiles
And android-build.xml is based on the build.xml file emitted by running:
android-sdk/tools/activityCreator.py
The build.xml files are then used by executing ant in the appropriate sub directory. By executing ant in the root all of the sub-projects are built. Eclipse is also capable of building using Ant but you have setup the properties for each sub-project, which I’ll try to outline below. Sometimes Eclipse has trouble and either won’t execute saying they are still errors or it won’t execute because the classpath isn’t set properly.
One solution that has helped is to delete all projects and re-import them. Two other important items is that the Run parameters must be setup properly in <Run/Open Run Dialog> must be set properly and Build parameters for must be good.
Anyway, here is an example of setting the project properties so that external Ant files are used for compiling, in the example below I’m setup the sub-project “debug”. We assume there is a build.xml file in the sub-project.
Project -> Properties -> Builders -> new:
Main.Name: = debug-build.xml
Main.Buildfile: = Browse Worksapce => debug/build.xml
Main.Base Directory: = Browse Workspace => debug
Targets.After a “Clean”: = <default target selected>
Targets.Manual Build: = <default target selected>
Targets.Auto Build: = <default target selected>
Targets.During a “Clean”: = clean
Project -> Properties -> Builders = select only debug-build.xml deselect all others
Project -> Propertiers -> java Build Path -> Libraries = Add appropriate Libraries
Project -> Propertiers -> java Build Path -> Order and Export = the Libraries
Project -> Propertiers -> Project References -> Project references for debug: = select appropriate projects
In the Project -> Properties -> Builders where we select only debug-build.xml and deselect all others includes the following if it is an Android sub-project:
Android Resource Manager
Android Pre Compiler
Java Builder
Android Package Builder
If it is “pure java” project than you just deselect Java Builder.