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.
- What is the concept of a “namespace” in Ant world? Is this
xmlns:ivy=attribute pointing towards a JAR? - Where would this
org.apache.ivy.antJAR/resources/whatever live? - What is
antliband 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 anorg/apache.ivy/antlib.xmlfile 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>/libdirectory. You can also start ant with-libto specify a different directory or just set theCLASSPATH(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.