You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Ghadi Mahmoudi <gh...@cosens.de> on 2008/12/12 13:06:18 UTC

Ant Task to read directly from a JAR Manifest file

Hello,

Is there alread a Task, which is able to read values from manifest file
(in a JAR)?

I prefer to avoid the long way of 1. unzip the JAR and 2. read the
value.

thanks,

Ghadi

 
M.Sc. Ghadi Mahmoudi
System Engineer


COSENS GmbH
Lerchenkamp 11
31137 Hildesheim
Tel.: +49 5121 17750-43
Fax: +49 5121 17750-49
E-Mail:  <ma...@cosens.de>
ghadi.mahmoudi@cosens.de
 <http://www.cosens.de/> www.cosens.de

Sitz der Gesellschaft: Hildesheim 
Handelsregister: Amtsgericht Hildesheim HRB 3620
Geschäftsführer: Dr. Hamed Amor

 

AW: Ant Task to read directly from a JAR Manifest file

Posted by Ja...@rzf.fin-nrw.de.
<project>

    <!-- Get a jar -->
    <copy file="${ant.home}/lib/ant.jar" todir="."/>

    <!--
    Loads entries from a manifest file.
    @jar     The jar from where to read
    @prefix  A prefix to prepend
    -->
    <macrodef name="loadmf">
        <attribute name="jar"/>
        <attribute name="prefix" default=""/>
        <sequential>
            <loadproperties>
                <!-- Load the manifest entries -->
                <zipentry zipfile="@{jar}" name="META-INF/MANIFEST.MF"/>
                <!-- Add the prefix -->
                <filterchain>
                    <prefixlines prefix="@{prefix}"/>
                </filterchain>
            </loadproperties>
        </sequential>
    </macrodef>

    <!-- Read mf entries -->
    <loadmf jar="ant.jar" prefix="ant-mf."/>
    <!-- Print them -->
    <echoproperties prefix="ant-mf."/>
    
</project>


Jan

 

>-----Ursprüngliche Nachricht-----
>Von: Francis Galiegue [mailto:fge@one2team.com] 
>Gesendet: Freitag, 12. Dezember 2008 13:24
>An: user@ant.apache.org
>Cc: Ghadi Mahmoudi
>Betreff: Re: Ant Task to read directly from a JAR Manifest file
>
>Le vendredi 12 décembre 2008, Ghadi Mahmoudi a écrit :
>> Hello,
>> 
>> Is there alread a Task, which is able to read values from 
>manifest file
>> (in a JAR)?
>> 
>> I prefer to avoid the long way of 1. unzip the JAR and 2. read the
>> value.
>> 
>> thanks,
>> 
>
>Not directly, but why not just make a macro? Like in (NOTE: 
>this example makes 
>use of ant-contrib, for <var>):
>
><property name="tmpdir" location="some/where/under/basedir"/>
><var name="value-from-manifest"/>
>
><macrodef name="read-from-manifest">
>	<attribute name="jar"/>
>	<attribute name="attr"/>
>	<sequential>
>		<unjar src="@{jar}" dest="${tmpdir}">
>			<patternset includes="META-INF/MANIFEST.MF"/>
>		</unjar>
>		<!--
>			Then do what's necessary to fill 
>$value-from-manifest
>			with the value of @attr; the manifest will be in
>			${tmpdir}/META-INF/MANIFEST.MF
>		-->
>	</sequential>
></macrodef>
>
>-- 
>Francis Galiegue
>ONE2TEAM
>Ingénieur système
>Mob : +33 (0) 6 83 87 78 75
>Tel : +33 (0) 1 78 94 55 52
>fge@one2team.com
>40 avenue Raymond Poincaré
>75116 Paris
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>

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


Re: Ant Task to read directly from a JAR Manifest file

Posted by Francis Galiegue <fg...@one2team.com>.
Le vendredi 12 décembre 2008, Ghadi Mahmoudi a écrit :
> Hello,
> 
> Is there alread a Task, which is able to read values from manifest file
> (in a JAR)?
> 
> I prefer to avoid the long way of 1. unzip the JAR and 2. read the
> value.
> 
> thanks,
> 

Not directly, but why not just make a macro? Like in (NOTE: this example makes 
use of ant-contrib, for <var>):

<property name="tmpdir" location="some/where/under/basedir"/>
<var name="value-from-manifest"/>

<macrodef name="read-from-manifest">
	<attribute name="jar"/>
	<attribute name="attr"/>
	<sequential>
		<unjar src="@{jar}" dest="${tmpdir}">
			<patternset includes="META-INF/MANIFEST.MF"/>
		</unjar>
		<!--
			Then do what's necessary to fill $value-from-manifest
			with the value of @attr; the manifest will be in
			${tmpdir}/META-INF/MANIFEST.MF
		-->
	</sequential>
</macrodef>

-- 
Francis Galiegue
ONE2TEAM
Ingénieur système
Mob : +33 (0) 6 83 87 78 75
Tel : +33 (0) 1 78 94 55 52
fge@one2team.com
40 avenue Raymond Poincaré
75116 Paris

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