• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

classpath setup by taking jars from multiple directory

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I have list of directories mentioned in Build.properties

build.classpath=dir/lib,dir1/lib,dir3/lib,dir5/xyz/lib

I would like to include all the jars present in dir,dir1,dir2,dir3,dir4,dir5. I dont want to define path id for each folder.Is there any way using dirset or fileset i can achieve this or is there any better way


Thanks
 
Ranch Hand
Posts: 81
Eclipse IDE Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, you can use the fileset present in the ant script to add all the jars present in a dir.

<javac>
<classpath>
<fileset dir="${lib.dir}">
<include name="*.jar" />
<exclude name="abc.jar" />
</fileset>
</classpath>
</javac>
 
siba swain
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Santhosh for quick response.but thing is that all these jars are not under one folder

  • dir/lib
    dir1/lib
    dir2/lib
    dir3/xyz/lib
    dir4/abc/lib.....like this 20 directories


  • if it is inside one parent folder then I would have done using your way. So I thought i would put this in the property file and loop through each folder to create the classpath usingdirset as follow.




    But this sort implemntation is not working
     
    Santhosh ayiappan
    Ranch Hand
    Posts: 81
    Eclipse IDE Oracle Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    You can have any number of fileset tag within the classpath tag.

    <classpath>
    <fileset dir="${lib.dir1}">
    <include name="*.jar" />
    </fileset>
    <fileset dir="${lib.dir2}">
    <include name="*.jar" />
    </fileset>
    </classpath>
     
    siba swain
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Earlier i had done that way but it made my build file very large.so I thought I will move these directory listing to property file and in build file I will use some loop or macro which will loop throgh these directories and create the build classpath
     
    author
    Posts: 5856
    7
    Android Eclipse IDE Ubuntu
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    To include all of the jar files within a directory and all subdirectories, use "<includes>**/*.jar</includes>".

    By the way, is this a classpath for running or for compiling? For compiling you only need to include the JARs that contain the classes mentioned in your import statements. For example, you might be using commons-logging with log4j. Only the commons-logging JAR is required to be in the classpath at compile time; but at runtime you would need both JARs.
     
    siba swain
    Greenhorn
    Posts: 10
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    This is how I did.

    1. First in build.properties I defined a variable that will list the lib dirs.
    lib.dirs=\
    DAS/lib,\
    DAS-UI/lib,\
    DPS/lib,\
    DSS/lib,\
    DCS/lib,\
    DAF/Search/Index/lib,\
    DAF/Search/Query/lib,\
    DAF/Search/common/lib
    2. Then in build.xmls, compile target I am forming the classpath as below.

    <target name="compile" depends="init" description="Compiles the source code to the build directory.">

    <var name="compile.class.path" value="" /> <!-- Defined a variable with null value -->

    <!-- Loop throgh the list lib.dirs -->
    <for list="${lib.dirs}" param="pathitem" delimiter=",">
    <sequential>
    <var name="compile.class.path" value="${compile.class.path},@{pathitem}/*.jar" />
    </sequential>
    </for>

    Now "compile.class.path" will contain all your jars.
     
    Consider Paul's rocket mass heater.
    reply
      Bookmark Topic Watch Topic
    • New Topic