ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jens v.P." <develo...@jevopi.de>
Subject Why are there paths and filesets?
Date Tue, 18 Dec 2001 10:57:11 GMT
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>


Mime
View raw message