Issue Details (XML | Word | Printable)

Key: XDT-1616
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: xdoclet-devel (Use for new issues)
Reporter: Chris Nappin
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XDoclet

If invoked twice springdoclet ignores destDir attribute

Created: 09/Mar/06 06:50 AM   Updated: 16/Aug/06 10:01 AM
Component/s: Spring Module
Affects Version/s: 1.2.3
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Windows XP, JDK 1.4.2, Spring 1.2.5, Ant 1.6.1


 Description  « Hide
If "springdoclet" is invoked twice, with different "destDir" attribute values, then on the second invocation the attribute value is ignored and the first one is used.

For example:

    <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.application}/spring-beans.xml"/>
        
        <!-- Generate the top level Spring application context -->
        <springdoclet destDir="${build.springdoclet.application}"
            mergeDir="${build.springdoclet.application}">
            <fileset dir="${admin.java}">
                <exclude name="com/abmuk/oms/admin/control/**/*Controller.java"/>
            </fileset>
            <springxml destinationFile="applicationContext.xml" validateXML="true"/>
        </springdoclet>
        
        <!-- copy the dispatcher merge files -->
        <copy file="${config}/dispatcher-beans.xml"
         tofile="${build.springdoclet.dispatcher}/spring-beans.xml"/>
        
        <!-- Generate the Spring dispatcher context -->
        <springdoclet destDir="${build.springdoclet.dispatcher}"
         mergeDir="${build.springdoclet.dispatcher}">
            <fileset dir="${admin.java}">
                <include name="com/abmuk/oms/admin/control/**/*Controller.java"/>
            </fileset>
            <springxml destinationFile="dispatcher-servlet.xml" validateXML="true"/>
        </springdoclet>
    </target>

The file "dispatcher-servlet.xml" is created in the directory corresponding to ${build.springdoclet.application}, not ${build.springdoclet.dispatcher} as expected. If the first "springdoclet" call is commented out, then the file is created in the expected directory.

Note that specifying the destDir on the "springxml" task instead of the "springdoclet" task causes an error (destDir is mandatory on springdoclet), contrary to the XDoclet 1.2.3 documentation.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
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!

Chris Nappin added a comment - 09/Mar/06 08:49 AM
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>

Gwyn Evans added a comment - 09/Mar/06 11:58 AM
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...

Matt Raible added a comment - 10/Mar/06 09:49 AM
I've backed out XDT-879 locally and my application continues to work. I revert the fix - hopefully it doesn't break things for others. If it does, at least it's not my responsibility anymore. ;-)

Matt Raible added a comment - 10/Mar/06 09:54 AM
Sorry, I meant to say "I can revert XDT-879" if you like.

Gwyn Evans added a comment - 10/Mar/06 10:01 AM
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...

Chris Nappin added a comment - 13/Mar/06 03:42 AM
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...

Zarar Siddiqi added a comment - 16/Aug/06 10:01 AM
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.