You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by David McLeod <dm...@vocent.com> on 2003/01/22 00:57:22 UTC

Nested "manifest" element inside "jar" task.

Is this a bug, or am I missing something?  I want to create a jar file if
and only if the class files have been updated, so naturally I have a target
for creating the jar file as follows:

    <target name="dist" depends="compile">
        <echo message="*** Creating ${moduleName} jarfile."/>
        <mkdir dir="${dist}/lib"/>
        <jar destfile="${jarLocation}/${jarFile}" basedir="${build}"
includes="${rootPath}/**/*.class" index="true"/>
    </target>

This works fine, with the jar file only being created when the class files
have actually been changed.  Now, I'd like to be able to update the internal
MANIFEST.MF file whenever the jar file is created, so I modify my target as
follows:

    <target name="dist" depends="compile">
        <echo message="*** Creating ${moduleName} jarfile."/>
        <mkdir dir="${dist}/lib"/>
        <jar destfile="${jarLocation}/${jarFile}" basedir="${build}"
includes="${rootPath}/**/*.class" index="true">
            <manifest>
                <attribute name="Build-Date" value="${buildDate}"/>
            </manifest>
        </jar>
    </target>

Now, the jar file is created EVERY TIME, even though none of the class files
have changed!  It doesn't make sense; ant should not even get inside the
<jar> task unless the class files have been touched, but it seems as if the
inclusion of the <manifest> sub-element creates an internal dependency that
I cannot control.

I ask the question again: is this a bug, or am I missing something?

Dave


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Nested "manifest" element inside "jar" task.

Posted by Conor MacNeill <co...@cortexebusiness.com.au>.
David McLeod wrote:
> Now, the jar file is created EVERY TIME, even though none of the class files
> have changed!  It doesn't make sense; ant should not even get inside the
> <jar> task unless the class files have been touched, but it seems as if the
> inclusion of the <manifest> sub-element creates an internal dependency that
> I cannot control.

The manifest is considered as much a part of the Jar as the classes in 
the Jar. As such, the new manifest is checked against the existing 
manifest to see if it has changed. In your case, since the value of the 
manifest is always changing the jar is always updated. You will need to 
use <uptodate> to control whether to run the <jar> task, setting up a 
relationship betweem the jar and the classes.

Conor


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>