You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Dmitri Pissarenko <di...@gmx.net> on 2004/08/29 14:57:02 UTC

Automatic creation of manifest file

Hello!

Some of my applications, which I package as an executable jar file,
depends on many other jar files.

These jar files are located in a subdirectory of the directory, in which
executable jar file resides.

Using the manifest file inside it, the executable jar knows where to
find all required classes.

The required jar files, on which the executable jar depends, vary from
build to build (because of newer versions). The manifest file must be
always updated whenever the dependencies of the executable jar change.

I want to write an ant task, which does the following:

1) Gets a list of all files in a certain directory (lib) with a certain
extension (*.jar). This step is equivalent to running linux command "ls
-1 lib/*.jar" and getting its output.

2) In the output of 1), newlines are replaced by spaces.

3) The result of 2) is put into the manifest file after "Class-Path".

The resulting manifest file should look like shown below.
<manifest>
Manifest-Version: 0.0.1
Created-By: Dmitri Pissarenko
Main-Class: com.dapissarenko.MyApp
Class-Path: lib/abbot.jar lib/bsh-2.0b1.jar lib/c3p0-0.8.4.5.jar
lib/cglib-full-2.0.1.jar lib/commons-collections-2.1.jar
lib/commons-logging-1.0.3.jar lib/dom4j-1.4.jar lib/ehcache-0.7.jar
lib/gnu-regexp-110.jar lib/hibernate2.jar lib/j2h.jar
lib/jdbc2_0-stdext.jar lib/jdom.jar lib/jgraph.jar lib/jgraphpad.jar
lib/jgrapht-0.5.2.jar lib/jta.jar lib/junit-3.8.1.jar lib/junitx-5.1.jar
lib/jxv-0.4.jar lib/log4j-1.2.8.jar lib/odmg-3.0.jar
lib/poi-2.0-RC1-20031102.jar lib/swixml.jar lib/ui.jar
lib/xalan-2.4.0.jar lib/xerces-2.4.0.jar lib/xml-apis.jar
</manifest>

My question is:

Does

*) an open-source Ant task, which
*) performs steps 1) to 3) (or similar) and which
*) can be used in commercial and non-commercial projects

exist?

If yes, where can I download it?

Many thanks in advance

Dmitri Pissarenko



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


Re: Automatic creation of manifest file

Posted by Dmitri Pissarenko <di...@gmx.net>.
Thanks!


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


Re: Automatic creation of manifest file

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
Dmitri Pissarenko wrote:
> Hello!
> 
> Some of my applications, which I package as an executable jar file,
> depends on many other jar files.
> 
> These jar files are located in a subdirectory of the directory, in which
> executable jar file resides.
> 
> Using the manifest file inside it, the executable jar knows where to
> find all required classes.
> 
> The required jar files, on which the executable jar depends, vary from
> build to build (because of newer versions). The manifest file must be
> always updated whenever the dependencies of the executable jar change.
> 
> I want to write an ant task, which does the following:
> 
> 1) Gets a list of all files in a certain directory (lib) with a certain
> extension (*.jar). This step is equivalent to running linux command "ls
> -1 lib/*.jar" and getting its output.
> 
> 2) In the output of 1), newlines are replaced by spaces.
> 
> 3) The result of 2) is put into the manifest file after "Class-Path".
> 

You can do a few things with existing Ant tasks to achieve what you want.

e.g. use pathconvert with a fileset to get the classpath into a property

<pathconvert dirsep="/" pathsep=" " property="war.classpath">
   <map from="${lib.app.dir}" to="lib"/>
   <path>
     <fileset dir="${lib.app.dir}">
       <include name="*xwork*"/>
       <include name="*webwork*"/>
       <include name="*velocity*"/>
       <include name="*ognl*"/>
     </fileset>
   </path>
</pathconvert>

and then

<war webxml="${appconf.dir}/web.xml" warfile="${war.file}">
   <manifest>
     <attribute name="Class-Path" value="${war.classpath}"/>
   </manifest>


Conor

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