legerdemain (10) [Avatar] Offline
#1
Hello,

Currently I'm utilizing templates to generate some files for me. I'm wondering if its possible, during this generation, to have Xdoclet reach out, determine if there is some specific text file in a certain place, and if so, to extract the text from that file and just automatically copy it into the file generated from the template? Hopefully this makes sense. Let me try to clear it up a bit.

While processing a file, say Room.java, I want to see if room.txt exists (if so it will be user created), and if so, I want to copy the contents of room.txt into the generated file RoomBean.java. So I would assume I would need to run this from within the template task...but I can't seem to figure out if its possible, and if so what tags I might use. Any thoughts? Thank you.
orb (16) [Avatar] Offline
#2
Re: Merging outside text
Merge files do exactly that. Look at Appendix B to see what merge files are available for the XDoclet subtask you are using.
habuma (279) [Avatar] Offline
#3
Re: Merging outside text
And if you've written your own task and/or template, you can use XdtMerge:merge (page 543) to merge in whatever files you want.
orb (16) [Avatar] Offline
#4
Re: Merging outside text
Sorry about that. Somehow I didn't read the part that said you were using your own templates. You'd think being an author would give me some reading comprehension skills. smilie
legerdemain (10) [Avatar] Offline
#5
Re: Merging outside text
Excellent, that will work perfectly. I was scanning the xdoclet template language and missed that entirely. Thanks so much smilie

One question regarding this capability though that I'm not clear on. I got things working, but currently I only seem to be able to store the merge files in the directory where the source files are. The source files are in a specific package com.mycompany.whatever.busobj. So currently I have the source parameter pointing at the top lvl /src under which is the /com/mycompany/etc. If i put the files somewhere other than the busobj folder in this path, so the only part of the path i'm changing is busobj to something else, then it will no longer find the files. Even if I point the mergedir attribute directly at the directory the files are in. Any idea how I would go about having mergedir look in a different place for these files? Here is an example of my ant task.

<target name="createService" depends="init">
<xdoclet destdir="${src.dir}" addedTags="@xdoclet-generated" >
mergedir="${src.dir}">
<packageSubstitution packages="busobj" substituteWith="service" />
<fileset dir="${src.dir}" includes="**/busobj/*.java" />
<template acceptInterfaces="false" >
acceptAbstractClasses="false"
templateFile="${basedir}/build/createIService.xdt"
destinationfile="I{0}Service.java" />
</xdoclet>

So the source files are in /src/com/mycompany/whatever/busobj. If I put the merge files here it works fine. But I want to put them in /src/com/mycompany/whatever/mergefiles. Any thoughts? Thanks so much for all your help.