Question

I would like to have a "modular" (reusable) Ant build that I can reuse across multiple projects. The build might be able to take a project (directory) name as input and run the same common targets on various projects' source code. This is to prevent having the same exact (or nearly exact) build.properties and build.xml files for each and every project.

So, given the following setup:

  1. build-base.properties is a "base" props file, containing properties that will exist for all buildscripts
  2. build-1.xml uses properties defined in build-base.properties as well as build-1.properties
  3. build-2.xml uses properties defined in build-base.properties as well as build-2.properties
  4. build-3.xml uses properties defined in build-base.properties as well as build-3.properties, and uses targets defined in both build-1.xml and build-2.xml

What would build-3.xml need to look like (basic structure) to import/use build-base.properties properties, and have access to build-1.xml/build-2.xml targets? Thanks in advance!

Was it helpful?

Solution

The best way I know to accomplish this type of modularity in Ant is to create an ant file to contain the common targets (call it common-targets.xml or whatever you like), and use the import task in the build-[n].xml property files. If you have troubles with properties not sharing the way you like, you should also look at utilizing macrodef.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top