ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: Why are there paths and filesets?
Date Tue, 18 Dec 2001 11:07:42 GMT
A path is an ordered list of files or directories.

A fileset is a rooted, from a single directory, collection (order
unspecified) of files.

You can define a fileset and give it an id, and re-use it inside a defined
path:

<fileset dir="some/directory" id="my.files"/>

<path id="my.path">
  <fileset refid="my.files"/>
</path>

So, no need to define anything twice and we'd all be complaining more if
this reusability was not available!  :)

    Erik



----- Original Message -----
From: "Jens v.P." <developer@jevopi.de>
To: "Ant Users" <ant-user@jakarta.apache.org>
Sent: Tuesday, December 18, 2001 5:57 AM
Subject: Why are there paths and filesets?


> Hello Ant Users,
>
>   I'm wondering why there exist two different concepts of list of
> files: path and fileset.
>   Both elements fullfill nearly the same purpose - so why are there
> two of them?
>
>   My problem is that they are not compatible. Using the javac-task, I
> have to define a path, the zip task requires a fileset. In my case -
> and I think it's a very common one - I have a compile and a zip
> target, the first one compiling all my java classes, the second one
> creating a zip containing all necessary binary files.
>   Both targets require my classpath, that is my list of all libs
> (jars), used for compiling and, of course, needed in a binary
> distribution. I don't want to define the list twice, so I define it this
way:
>
> -----------8X-------------------------------------------8X-----------
> <?xml version="1.0" encoding="UTF-8"?>
> <project name="test" basedir="." default="compile">
>         <property name="src" value="src"/>
>     <property name="lib" value="lib"/>
>         <property name="build" value="build"/>
>     <property name="build.classes" value="${build}/classes"/>
>     <property name="build.dist" value="${build}/dist"/>
>
>         <property name="libs"
value="${lib}/jdom.jar;[...];${lib}/batik.jar;${lib}/fop.jar" />
>
>     <target name="init">
>         <path id="lib.path">
>             <pathelement path="${libs}" />
>         </path>
>
>         <pathconvert property="lib.fileset" pathsep="," dirsep="/"
refid="lib.path">
>                 <map from="${basedir}\" to=""/>
>                 <map from="${basedir}/" to=""/>
>         </pathconvert>
>     </target>
>
>         <target name="compile" description="Compile the source files"
depends="init">
>        <mkdir dir="${build.classes}"/>
>        <javac srcdir="${src}" destdir="${build.classes}" deprecation="off"
classpathref="lib.path" includeAntRuntime="false">
>            <exclude name="**/*.html;**/Makefile" />
>        </javac>
>     </target>
>
>     <target name="makezip" description="Zip all libs" depends="init">
>         <echo>${lib.fileset}</echo>
>        <mkdir dir="${build.dist}"/>
>        <zip zipfile="${build.dist}/${ant.project.name}_bin.zip">
>             <fileset dir="${basedir}" includes="${lib.fileset}" />
>        </zip>
>         </target>
> </project>
> -----------8X-------------------------------------------8X-----------
>
>   It's working - but I think this way looks quite like a workaround.
> The workaround is placed in target init where, based on the
> properterty "libs" two kind of file lists (a path and a fileset) are
> generated.
>   Is there another way of solving the problem? And I've got still the
> question: Why is there a fileset and a path definition, if, as shown
> in my example, both are fullfilling the same requirements?
>
> Best regards,
>  Jens
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-user-help@jakarta.apache.org>


Mime
View raw message