Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem including external jar to build.xml file Ant

 
Kacee Saxena
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Friends,

I am not getting how to add external libraries to build file used by Ant. I want to use classes12.jar and ojdbc14.jar in my java code. But i dont know how to incldue them in the existing build.xml. Here is an excerpt of my build file :

<property name="dest.classpath" value="/usr/local/xml/xerces-j-2.0.1/bin/xercesImpl.jar /us
r/local/xml/xerces-j-2.0.1/bin/xmlParserAPIs.jar /opt/oracle/sol-9.2.0/jdbc/lib/classes12.zip /proje
ct/tpf95/oracle/classes12.zip /opt/oracle/sol-9.2.0/jdbc/lib/classes12.jar /opt/oracle/sol-9.2.0/jdb
c/lib/ojdbc14.jar"/>

<path id="local.xerces.classpath">
<fileset dir="/usr/local/xml/xerces-j-2.0.1/bin" id="xerces.jar">
<include name="xercesImpl.jar"/>
<exclude name="xmlParseAPIs.jar"/>
</fileset>
</path>


Do i need to include these jars in path element as well ? If yes , then how ? Also how to decide the syntax of path id ?
eg. <path id = "xx.yy.zz">

what should be xx,yy,zz ?

Any help would be highly appreciable.
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure why you are using a property - that won't do anything unless you refer to that property later when declarinf a path.

The id for path is anything - it is a name that you can use later in the build script. Therefore, is is like a property name, but speciifc for use in paths, such as a classpath. This is generally true for every place where an id can be specified.

I usually set up classpaths using two mechanisms. For specific JAR files, I use 'pathelement location', but to grab all (or almost all) of the JARfiles within a directory (and its subdirectories) I use fileset. For example, if I want to define a classpath using all of the JAR files you mentioned in the dest.classpath property, I would use:



The above makes the assumption that only the JAR files list are in those directories. (I question the use of classes12.zip - that is an really old file if I recall correctly, but I left it in there to make the example complete.)

To use the above, in a later task I would use the dest.classpath:



By the way, I really recommend a book such as Ant In Action - I have a copy of the previous edition and it was invaluable.
 
Kacee Saxena
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please provide the link for downloading this e-book ?
 
Kacee Saxena
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already added those jar files using fileset and its working. Thanks for letting me know when to use path element and fileset. Thanks for the help
 
Peter Johnson
author
Bartender
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kacee, you can google Ant In Action as easily as I can...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic