tags:

views:

33

answers:

3

Here is my Ant script for generating jar package. I have bunch of jar packages for manifest Class-Path attribute, they are all in an specific folder. I don't want to hard code it, how can I get them automatically?


          <jar jarfile="${client_deploy_dir}/HelloWorld.jar" basedir="${client_work_dir}/compiled">
              <manifest>
                 <attribute name="Main-Class" value="HelloWorld.Main"/>
                 <attribute name="Class-Path" value="???"/>
              </manifest>
           </jar>

Thanks

A: 

Check out the ant pathconvert task. You can use this to expand an existing fileset into a list of files.

krock
Yes, pathconvert does help me. I set attribute pathsep="${line.separator}lib/".
Rick Wang
No need for pathconvert. The manifestclasspath task is capable of generating relative links to the eventual jarfile
Mark O'Connor
A: 

You're on the right track, use manifestclasspath task. The jarfile attribute is used to create relative links to the jars contained in the fileset.

<manifestclasspath property="jar.classpath" jarfile="${client_work_dir}/HelloWorld.jar">
    <fileset name="" dir="${client_work_dir}/lib" >
        <include name="*.jar"/>
    </fileset>
</manifestclasspath>

<jar jarfile="${client_deploy_dir}/HelloWorld.jar" basedir="${client_work_dir}/compiled">
    <manifest>
         <attribute name="Main-Class" value="HelloWorld.Main"/>
         <attribute name="Class-Path" value=""${jar.classpath}"/>
      </manifest>
   </jar>
Mark O'Connor
A: 

Now, the problem I have is the wrong format in MANIFEST.MF:

Here is Class-Path in my MANIFEST.MF


 Class-Path: lib/DirtyListener.jar
   lib/Recurring.jar

   lib/RowSet.jar
   lib/activation.jar
   lib/bfor
  eport.jar
   lib/borlandxml.jar
   lib/commons-l
  ang-1.0.jar
   lib/crimson.jar

How can I get rid of the empty row and avoid the hard new line?

Rick Wang