ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Jan.Mate...@rzf.fin-nrw.de>
Subject AW: Ant Task to read directly from a JAR Manifest file
Date Mon, 15 Dec 2008 06:40:14 GMT
<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


Mime
View raw message