开发者

Updating files in a WAR/JAR reguardless of their date

I have an ANT task that uses the jar task to update a few files inside of a previously built war. [The files are processed between compilation of a WAR and deliverable.] How can I get ANT to update all of the files I've specified to be updated? There is an attribute for jar called update = "[...]" that will allow you to either force a new creation of the Jar file or (add new files/"update existing ones if deemed necessary").

An example:

  1. Java class(es) are compiled
  2. Jars are created
  3. A .war is created
  4. A script runs to modify the Jars
  5. The .war needs to update the Jars that were modified [the Jars are a subset of all of the files in the war]

The problem I'm running into is that the Jars that are being instructed to be updated aren't getting updated in the final step. The log claims that the just processed Jars are "out of date." Is there a way I can force the update to happen? If I switch "jar [...] update" back to false (which its by default) the correct Jar files get placed there, but the rest of the files in the war don't.

Note I realize that this could be moved to produce the WAR after everything is done. But this is not an option for me.

The ant task in question:

<target name="(the 'Rewaring task')" depends="step-3">
    <echo>Adding modifed jars to war</echo>
    <jar destfile="${output.war.dir}/existing.war" update="true">
        <zipfileset dir="${output.jar.dir}/modded-jars" prefix="folder" />
    </jar>
</target>

More specifically, the problem I'm having is w开发者_如何学JAVAith the "update" behavior.


It looks like the Jar task is correct.

Are you sure the files being updated have the correct Date modified time - that is what is actually compared in the zipfileset/update option?

I've seen this issue when signing Jars [and had the preservelastmodified option set to "true" (default : false)].

To fix it, you should only need to change the signing option.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜