|
[
Permalink
| « Hide
]
Chris Nappin added a comment - 09/Mar/06 08:16 AM
Hmmm. I've also noticed the same fault with the mergeDir attribute as well, i.e. in the example above the second invocation of "springdoclet" is using the first "spring-beans.xml" file to merge with!
No wait, it's WAY more wierd than that.
The entire contents of the merge directory appears to be cached in memory in between invocations. If I use the same directory for both invocations, deleting it's contents inbetween for good measure, the second invocation still merges the first merge file, even though it no longer exists on disk! The "force" flag doesn't help, moving the mergeDir to the springxml rather than springdoclet makes no difference, and the "verbose" flag doesn't do anything at all. Upgrading to Ant 1.6.5 makes no difference either. My latest Ant code is as follows: <target name="springdoclet"> <taskdef name="springdoclet" classpathref="ant.path" classname="xdoclet.modules.spring.SpringDocletTask"/> <!-- copy the application context merge files --> <copy file="${config}/application-beans.xml" tofile="${build.springdoclet.temp}/spring-beans.xml"/> <!-- Generate the top level Spring application context --> <springdoclet destDir="${build.springdoclet}" verbose="true" force="true"> <fileset dir="${admin.java}"> <exclude name="com/abmuk/oms/admin/control/**/*Controller.java"/> </fileset> <springxml destinationFile="applicationContext.xml" mergeDir="${build.springdoclet.temp}" validateXML="true"/> </springdoclet> <delete> <fileset dir="${build.springdoclet.temp}"/> </delete> <!-- copy the dispatcher merge files --> <copy file="${config}/dispatcher-beans.xml" tofile="${build.springdoclet.temp}/spring-beans.xml"/> <!-- Generate the Spring dispatcher context --> <springdoclet destDir="${build.springdoclet}" verbose="true" force="true"> <fileset dir="${admin.java}"> <include name="com/abmuk/oms/admin/control/**/*Controller.java"/> </fileset> <springxml destinationFile="dispatcher-servlet.xml" mergeDir="${build.springdoclet.temp}" validateXML="true"/> </springdoclet> </target> This looks as if it might be the same as http://opensource2.atlassian.com/projects/xdoclet/browse/XDT-1505, although that's probably only going to help if you back-out the http://opensource2.atlassian.com/projects/xdoclet/browse/XDT-879 patch that reportedly causes the issue. I've not tried that myself yet...
I've backed out
Sorry, I meant to say "I can revert
One workaround that seems to have worked for me is to split the various calls to the XDoclet tasks into discreete Ant targets, then invoke them from a main target via antcall...
Please ignore my third comment, this was actually due to Ant not copying files. Adding "overwrite=true" to the copy task fixes this.
A simpler work around that appears to work for me is to use a common merge and dest dir, and split each call into a dependent sub-target. But your mileage may vary... I'm not advocating doing this but there is another workaround. Just re-initialize the springdoclet taskdef before you call it the second time and it will work. To make life neater/easier, use a macro:
<macrodef name="springdocletmacro"> <attribute name="destDir"/> <attribute name="mergeDir"/> <attribute name="srcDir"/> <attribute name="destFile"/> <sequential> <taskdef name="springdoclet" classname="xdoclet.modules.spring.SpringDocletTask" classpathref="xdoclet.classpath" > </taskdef> <springdoclet destDir="@{destDir}" mergeDir="@{mergeDir}"> <fileset dir="@{srcDir}"/> <springxml destinationFile="@{destFile}" validateXML="true"/> </springdoclet> </sequential> </macrodef> and then call it like this: <springdocletmacro srcDir="${src.dir}" mergeDir="${merge.dir}" destDir="${output.dir}" destFile="applicationContext.xml"/> I think this is a little better than having multiple ant tasks. |
|||||||||||||||||||||||||||||||||||||||||||||