ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Martin Olsson" <mn...@minimum.se>
Subject Generate manifest classpath with relative paths
Date Mon, 11 Jul 2005 08:44:59 GMT
Hi,

At runtime my program is stored like this:

./myprogram.jar
./lib/commons/commons-net.jar
./lib/commons/commons-configuration.jar
./lib/spring/spring_jar1.jar
./lib/spring/spring_jar2.jar
./lib/some/other/jarfile.jar

There is a ton of other .jar files too organized in the directory tree
below ./lib/ and there is so many of them that I can't just put all of
them directly in the lib directory.

---

I already have an ANT target that creates myprogram.jar but I also need it
to create a manifest with a proper Class-Path pointing to
./lib/commons/commons-net.jar etc etc

I managed to implement this using _absolute_ paths in the manifest but so
far I have not been able to get the paths to be _relative_. I've looked at
pathconvert and a bunch of mappers with no success. I'm using ANT 1.6.5
right now. Ideally, I would like to accomplish this without any custom ANT
tasks because my program is built by a lot of people and I do not want to
force all of them to fiddle with the extra ant task installation
procedure.

Below is my ANT target so far:

   <!--
====================================================================
-->
   <!-- Compress to .JAR                                                  
  -->
   <!--
====================================================================
-->

   <target name="dist" depends="compile">
      <mkdir dir="${build.dist.dir}/lib"/>
      <copy todir="${build.dist.dir}/lib">
         <fileset dir="${lib.runtime.dir}" includes="**/*.jar"/>
      </copy>
      <path id="manifest.classpath.path">
         <fileset dir="${build.dist.dir}" includes="lib/**/*.jar"/>
      </path>
      <pathconvert property="manifest.classpath.prop" pathsep=" ">
        <path refid="manifest.classpath.path"/>
      </pathconvert>
      <jar destfile="${build.dist.dir}/${dist.jar.filename}">
         <fileset dir="${build.classes.dir}" includes="**/*.class"/>
         <manifest>
            <attribute name="Built-By" value="${user.name}"/>
            <attribute name="Main-Class" value="${project.main.class}"/>
            <attribute name="Class-Path" value="${manifest.classpath.prop}"/>
         </manifest>
      </jar>
   </target>




regards,
martin

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


Mime
View raw message