ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From efe4it <>
Subject Needs clarification on nested <import><include> behavior
Date Tue, 26 Oct 2010 20:47:29 GMT


I encounter some difficulties using the import/include mecanism and I need
some advice.

My environment is:
	JDK Sun-1.6.0_06
	ANT-1.8.1 with antcontrib-1.0b3 & antunit-1.1 in ANT_HOME/lib/
I am trying to set up a custom build environment, defining antlibs and
scriptlets to be reused across multiple projects.
I have defined some macrodefs in antlib form and assembled a JAR dropped
into ANT_HOME/lib
I am now working on thematic scriptlets, like java-project-layout,
checkstyle, ...

Next I intend define multiple template buildfile, that reference the
scriptlets target by inclusion (<include>), because I do not intend to
override the targets in the template.

These template are to be referenced by import (<import>) by the project's
I want to use import because some of the template's targets must be
overriden to adapt to the project's specific configuration.

For instance, my "-main-compile" target need a different classpath
configuration in every project and use the
following target as customizer:
<target name="-main-compile-additional-classpath-setup" depends="-init">
	<echo level="verbose" message="[-main-compile-additional-classpath-setup]
override this target to add external libraries" />
	<path id="id.cp.compile.main.additional" />

As ANT was complaining about missing target, I set up simpler test scenario
using two-level include/import hierarchy and a simple usage target in each
file echoing the buildfile name.
There as 4 possible configurations with child (include|import) father
(include|import) grandpa. 

See attachment

Result are summarized here
1/ build.xml -> include -> include : ok
2/ build.xml -> import -> import   : ok
3/ build.xml -> include -> import  : ko
Target "f-included#gp-imported#gp-usage" does not exist in the project
"child". It is used from target "f-included#f-usage" 
4/ build.xml -> import -> include  : ko (missing target in imported.xml)
Target "gp-included#gp-usage" does not exist in the project "child". It is
used from target "f-imported#f-usage".

Target available as displayed with "ant -p"
1/  include include: as I expected, father-prefix for father targer and
(father+grandpa)-prefix for grandpa targets

2/ import import: as I expected, no prefix for any target

3/ include import: I expected to get father-prefix for father and grandpa
target but got

4/ import include: I expected to get no prefix for father target and
granpa-prefix for grandpa target but got

Any help appreciated


View this message in context:
Sent from the Ant - Users mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message