I was looking at an Ant build.xml
file this morning and noticed an XML namspace delcaration in the root <project>
element:
<project name="${project.name}" xmlns:ivy="antlib:org.apache.ivy.ant">
I figure this XML namespace is so that all of the Ivy tasks sprinkled throughout the buildscript know which resource to look inside for task definitions (<ivy:configure>
, <ivy:resolve>
, etc.), but was hoping for a more thorough explanation of the syntax of this statement.
xmlns:ivy=
attribute pointing towards a JAR?org.apache.ivy.ant
JAR/resources/whatever live?antlib
and where is it defined?Also, just a fleeting thought here, do Ivy files (ivy.xml
) have the ability to import properties files and use their property values? I looked in the Ivy documentation but couldn't find references to any import-type statements.
Thanks in advance!
The namespace is just like any other namespace as far as XML is concerned. But, Ant is using antlib:
as a URL scheme to know that it should look for an org/apache.ivy/antlib.xml
file in the classpath. See the antlib Type in the Ant manual.
Since it's looking for a classpath, the antlib.xml can be anywhere a classloader can find it. The default setup is to put the necessary jar file in the <ant install>/lib
directory. You can also start ant with -lib
to specify a different directory or just set the CLASSPATH
(not recommended).
Yes, you can can import properties files. See the Ivy manual info on multi-projects. Ivy supports the ${property}
syntax and you can use Ant's <property>
task to load a file that Ivy can use. You can also use <property>
elements in ivysettings.xml if you want to define 'global' values for Ivy.