I am using ant script for generating war file, it will generate the war file. please see the below script
<target name="war" depends="build">
<mkdir dir="${dist}" />
<jar destfile="${dist}/${pro开发者_如何学Pythonj_name}.war" basedir="${build}" />
</target>
If it generates a new war file, then i want to have a property to set the value as "newupdates" otherwise i want to know "noupdates"
A strategy to do this could be to use the UpToDate task to set the property. You just have to copy the war file to war.bak just after performing the uptodate check, to prepare for the next run.
Another strategy (probably even better) would be to use the UpToDate task to determine if the war has to be generated, setting a property, e.g myuptodateproperty
. Then call your war generation target, and make sure it has an if=${myuptodateproperty}
constraint, in order not to regenerate the war if it is not needed.
You can use something in the line of (untested code, may need some work):
<target name="war" depends="clean,fillbuildanddist,build">
<mkdir dir="${dist}" />
<uptodate targetfile="${dist}/${proj_name}.war" property="uptodatewar">
<fileset dir="${build}" />
</uptodate>
<antcall target="makewar" />
</target>
<target name="makewar" unless="uptodatewar">
<jar destfile="${dist}/${proj_name}.war" basedir="${build}" />
</target>
With this, the property uptodatewar
should be set to true
only if the war does not need to be rebuilt, and thus the jar
task will only be called in this case. In targets that depend on the war
target, you can use the uptodatewar
to perform tasks only if the war is new.
精彩评论