Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Opinion on this build.xml file I wrote

 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
project name="Guest Book" default="build" basedir=".">

<target name="build" >

<javac srcdir="C:\apache-tomcat-6.0.10\webapps\Guest Book\WEB-INF\classes"
destdir="C:\apache-tomcat-6.0.10\webapps\Guest Book\WEB-INF\classes"
classpath="C:\apache-tomcat-6.0.10\lib\servlet-api.jar" debug="true" includes="**/*.java"/>
</target>

</project>

What do you all think of this? Please suggest better ways of writing the same.
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about



You could even keep the tomcatDir and servletLib properties in a global property file, since they are likely to be used in other build files as well. That way you only need to change them in a single location if necessary.
[ May 16, 2007: Message edited by: Ulf Dittmer ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I prefer to declare paths in property tags.
For example , one for the path to the root of the application (C:\apache-tomcat-6.0.10\webapps\Guest Book), one for the source (reusing the previous property), one for the destination, one for external libraries.
<property name="app.root" value="C:\apache-tomcat-6.0.10\webapps\Guest Book" />
<property name="app.src" value="..." />
<property name="app.classes" value="${app.root}\WEB-INF\classes" />

2. It's not an Ant related, but I would not put source files in the classes directory
 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

<property name="servletLib" value="${tomcatDir}\lib\servlet-api.jar">

Can I use this like :
<property name="servletLib" value="${tomcatDir}\lib\" includes ="*.jar"> ???

Like, I am thinking if there is a situation where multiple jar files need to be used?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this should cover all the bases:

[ May 16, 2007: Message edited by: Ulf Dittmer ]
 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<property name="tomcatDir" value="C:\apache-tomcat-6.0.10\">

<property name="servletLib" value="${tomcatDir}\lib\servlet-api.jar">

<property name="webAppDir" value="${tomcatDir}\webapps\Guest Book">

<property name="classDir" value="${webAppDir}\WEB-INF\classes">

<path id="class.path">
<fileset dir="${webAppDir}/WEB-INF/lib">
<include name="*.jar"/>
</fileset>
<pathelement path="${servletLib}" />
</path>


I am thinking, why do we need the path element when we already have specified all the jar files in the fileset dir?
Using servletLib, we are still pointed to servlet-api.jar right? or is that how it is done, we point to all the jar files we need to add one by one and those will be the path elements??
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A path can contain any number of filesets and pathelements, so yes, this is necessary. These concepts are explained in detail with many examples in the Ant manual.
 
v ray
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I got it, thank you so much for clearing all my doubts!
 
Padma priya Gururajan
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf,
Where is the Ant Manual available?
With regards,
Padma priya N.G.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic