<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:[email protected]]
>Gesendet: Freitag, 12. Dezember 2008 13:24
>An: [email protected]
>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
>[email protected]
>40 avenue Raymond Poincaré
>75116 Paris
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [email protected]
>For additional commands, e-mail: [email protected]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]