• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Opinion on this build.xml file I wrote

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I got it, thank you so much for clearing all my doubts!
 
Ranch Hand
Posts: 437
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf,
Where is the Ant Manual available?
With regards,
Padma priya N.G.
 
This tiny ad is guaranteed to be gluten free.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic