ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Scassa <>
Subject RE: property names
Date Mon, 07 May 2001 17:27:09 GMT
Ok. Thanks for the responses:

Here is my INIT target:

<target name="init" depends="setBuildNo">
		<property name="sourceDir" value="src"/>
		<property name="ver" value="1.0"/>
		<property name="buildID"
		<property name="distDir" value="${buildID}"/>
		<property name="outputDir" value="${buildID}/classesMain"/>
		<property name="pubDir" value="${buildID}/docpublic"/>
		<property name="privDir" value="${buildID}/docprivate"/>
		<property name="publishPublic"
		<property name="publishPrivate"
		<propertyfile file="">
			<entry key="buildID" value="${buildID}"/>
		<path id="main.classpath">
			<fileset dir="lib">
				<include name="*.jar"/>

I know that I should have most of this stuff in a property file. I will get
to that. Now the <path id="main.classpath"> doesn't work for some reason. I
am getting the standard, "Could not create task of type: path. Common
solutions are to use taskdef to declare your task, or, if this is an
optional task, to put the optional.jar in the lib directory of your ant
installation (ANT_HOME)." I've got the optional jar installed, but don't
think it is necessary for the path id task.

Any ideas?  Do I "need" to include <pathelement location="classes"/> ?


-----Original Message-----
From: Conor MacNeill []
Sent: Monday, May 07, 2001 11:26 AM
Subject: Re: property names


I try to run Ant without a classpath which means managing classpaths within
the build file as much as possible. You basically are going to need to
decide which tasks will need classpaths. Most likely we are taking about
the <javac> task.

Ant lets you create paths at the same level as properties. You can create a
path like this

    <path id="blah.classpath">
        <pathelement location="/funky/fubar.jar"/>

You will now be able to refer to his path for <javac>
        <javac ...>
            <classpath refid="blah.classpath"/>

You can build up paths from other paths and also from filesets
    <path id="lib.classpath">
        <fileset dir="lib">
            <include name="*.jar"/>

    <path id="everything.classpath">
        <path refid="lib.classpath"/>
        <path refid="blah.classpath"/>

You CAN'T pass classpaths from one build file to another. To do that in Ant
1.x you need to go through a string property.

Convert the classpath to a property

<property name="classpath.string" refid="everything.classpath"/>

You can then pick that property up in the child build and turn it back into
a path

    <path id="child.classpath">
      <pathelement path="${classpath.string}"/>


----- Original Message -----
From: "David Scassa" <>
To: <>
Sent: Tuesday, May 08, 2001 1:38 AM
Subject: RE: property names

> Fellow ANTiers,
> Ok. Perhaps the documentation provided with ant doesn't cover this issue.
> I've also searched far and wide on the ANT USER List. I ventured into the
> Ant Development list and realized, that was certainly not for me. My
> is that I am attempting to exhaust all of the resources available before
> posting my questions. So here goes:
> Up till now, I have not had reason to try and set the classpath from
> a property file or within a build.xml file. The build was simple enough
> I set my classpath variables with an external Win2k batch file, then
> executed ANT; everything ran perfectly.
> 1. I am building two different projects with a branched .xml tree. I've
> a build-script that is called "autobuild.xml" which then calls server.xml
> and webapps.xml. The Top level autobuild.xml is mostly responsible for
> packaging the .class files into jars and moving them to the correct
> locations, etc.
> My Problem: server.xml uses one classpath, webapps.xml is starting to
> deviate on required .jars. An example would be that we now have two
> different versions of xerces.jar. I need to build server.xml with
> /lib/xerces.jar and webapps.xml with /webapps/lib/xerces.jar... How do I
> change classpaths midstream? For that matter, how do I set the classpath
> from within ANT? Is it as simple as defining a <property name="classpath"
> value="../../*.jar"/>?
> 2. Now that I have developers adding .jar files to the /lib folder at
> leisure; has anyone found a way to scan the /lib folder and build a
> classpath dynamically?
>    I found this snippet in the ANT User Archives:
> <classpath>
> <pathelement path="${classpath}"/>
> <fileset dir="lib">
> <include name="**/*.jar"/>
> </fileset>
> <pathelement location="classes"/>
> </classpath>
> When I attempt to execute this, it gives me the "could not create task of
> type... Put optional.jar in the ant/lib folder. (It is there, and I
> find a optional task to support classpath anyway, so I figured it was
> "included" with ant.)
> Thanks for any responses...
> -David
> -----Original Message-----
> From: Diane Holt []
> Sent: Wednesday, April 11, 2001 12:35 PM
> To:
> Subject: RE: property names
> As with any property, these are just ways of assigning a value to a name
> that can then be referenced by that name. For example, if you hard-coded
> value for the 'debug' attribute to "on" in every <javac> task instead,
> you then wanted to change it to "off", you would need to go through and
> change it in every <javac> task in your build-file(s) -- whereas, if you
> set a property (called "debug" in your example) to hold the value, you
> could then reference that property in your <javac> tasks attributes:
>   <javac debug="${debug}"
>          optimize="${optimize}"
>   [etc.]
> Then to change the attribute's value, you would only need to change the
> *property's* definition (ie., in one place, rather than in every <javac>
> task).
> The "classpath" property in your example serves both that purpose as well
> as serving as a short-hand -- it's much cleaner/easier/less-error-prone
> type in a long list of paths in one place, then reference that list using
> ${classpath} that it would be to repeat that long list everywhere it was
> needed.
> Diane
> --- Pinar Bicioglu <> wrote:
> >
> > I've one more question. So when we say <property name="debug"
> > />,
> > what do we really mean. Same thing for <property name="optimize"
> > value="false" />.
> >
> > Could you also please help me to understand with the one below.
> >
> > property name="classpath"
> >
> >
> > /jbcl3.0.jar" />
> >
> > Sorry for all of these silly and easy questions I ask. But since I have
> > only
> > one source to reference, I get stuck very often :(
> >
> > -----Original Message-----
> > From: Diane Holt []
> > Sent: Wednesday, April 11, 2001 12:36 PM
> > To:
> > Subject: Re: property names
> >
> >
> > A property is a way to associate a value with a name that can then be
> > referenced by that name, using the form ${property_name}. The property
> > name is whatever you want to call it, although it's usually a good idea
> > to
> > call it something that says something about the value it holds. For
> > example, a property to hold the path to the top of the source tree
> > be called "srcdir". Properties are used to allow for a variable value
> > as a means of having a short-hand way of referring to something.
> >
> > Diane
> >
> > --- Pinar Bicioglu <> wrote:
> > >
> > > Hi,
> > >
> > > Could someone please axplain to me what the "propery name" is?
> > Actually
> > > the
> > > question is how do we specify those? I have this build.xml file that
> > > sets
> > > the compiler and location options using <property name > tag. And I
> > have
> > > another build.xml file as a sample that sets different propert names.
> > > Are
> > > the names standard?
> > >
> > > Thanks
> >
> >
> > =====
> > (
> >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Get email at your own domain with Yahoo! Mail.
> >
> =====
> (
> __________________________________________________
> Do You Yahoo!?
> Get email at your own domain with Yahoo! Mail.

View raw message