legerdemain (10) [Avatar] Offline
#1
Hello, I've posted this before but I've noticed that after an initial response my posts no longer get looked at. I'm really at my wits end here. Whenever there is a package statement in a source file that I'm running a custom XDoclet template on, XDoclet skips that particular file. Any file without a package statement works, but with a package statement it doesn't work. Anyone have any ideas? I'm reposting the build file below.

One though I've had (because I've noticed this is true with javadoc comments that are not well formed), is that perhaps the entire source file is not well formed and XDoclet has issue with this? Any thoughts? Please, this is very important for a business project I'm working on and I'm at a complete loss as to why its happening. Otherwise I've had great success.

<project name="JB" default="compile" basedir=".">

<property environment="env"/>
<property name="src.dir" value="${basedir}/src"/>
<property name="build.dir" value="${basedir}/build"/>
<property name="todo.dir" value="${basedir}/todo"/>
<property name="lib.dir" location="${env.ANT_HOME}/lib"/>
<property name="xdoclet.lib.dir" location="${env.XDOCLET_HOME}lib"/>

<path id="xdoclet.lib.path">
<fileset dir="${lib.dir}" includes="*.jar"/>
<fileset dir="${xdoclet.lib.dir}" includes="*.jar"/>
</path>

<!-- =================================================================== -->
<!-- TaskDefs -->
<!-- =================================================================== -->
<taskdef name="documentdoclet" >
classname="xdoclet.modules.doc.DocumentDocletTask"
classpathref="xdoclet.lib.path" />

<taskdef name="xdoclet" >
classname="xdoclet.DocletTask"
classpathref="xdoclet.lib.path" />

<!-- =================================================================== -->
<!-- Init -->
<!-- =================================================================== -->
<target name="init">
<tstamp/>
<mkdir dir="${build.dir}"/>
</target>

<!-- =================================================================== -->
<!-- Todo -->
<!-- =================================================================== -->
<!-- <target name="todo"> <br /> <documentdoclet destdir="${basedir}/todo"> <br /> <fileset dir="${src.dir}"> <br /> <include name="**/*.java" /> <br /> </fileset> <br /> <info /> <br /> </documentdoclet> <br /> </target> <br /> -->
<!-- =================================================================== -->
<!-- Summary -->
<!-- =================================================================== -->
<target name="summary" depends="init">
<xdoclet destdir="${build.dir}">
<fileset dir="${src.dir}" includes="**/*.java" />
<template templateFile="summary.xdt" >
destinationfile="summary.txt" />
</xdoclet>
</target>

<!-- =================================================================== -->
<!-- Transform -->
<!-- =================================================================== -->
<target name="transform" depends="init">
<xdoclet destdir="${src.dir}" addedTags="@xdoclet-generated">
<fileset dir="${src.dir}" includes="**/*.java" />
<template acceptInterfaces="false" >
acceptAbstractClasses="false"
templateFile="transform.xdt"
destinationfile="{0}Bean.java" />
</xdoclet>
</target>

<!-- =================================================================== -->
<!-- Compile -->
<!-- =================================================================== -->
<target name="compile" depends="init">

<echo>+---------------------------------------------------+</echo>
<echo>| |</echo>
<echo>| C O M P I L I N G S O U R C E S |</echo>
<echo>| |</echo>
<echo>+---------------------------------------------------+</echo>

<javac srcdir="${src.dir}" destdir="${build.dir}"/>

</target>

<!-- =================================================================== -->
<!-- Clean -->
<!-- =================================================================== -->
<target name="clean">
<delete dir="${todo.dir}"/>
<delete dir="${build.dir}"/>
</target>

</project>
habuma (279) [Avatar] Offline
#2
Re: Please help! Package statements still causing issue.
Are you saying that if you were to remove the package statement that XDoclet picks up the file and runs with it? If so, then does that mean that you repackaged the class to be in the default package (including moving it to the root of the source directory) or do you just remove the package statement and leave the file where it is?

Could you also post one of the Java files you're having trouble with?
habuma (279) [Avatar] Offline
#3
Re: Please help! Package statements still causing issue.
One other thing...I also notice that you have 2 or 3 different XDoclet generations going on. Is there any one of those that doesn't work or is it any of them?
habuma (279) [Avatar] Offline
#4
Re: Please help! Package statements still causing issue.
Okay...one more thing to help clear this up. I notice that you're using some custom XDT files. Could you post one of them?
orb (16) [Avatar] Offline
#5
Re: Please help! Package statements still causing issue.
I reread this just now and I think I understand what you are expressing. You have a file, for example, in the file src/MyClass.java. If that class has no package statement, XDoclet will process it normally. If you put, "package com.mycompany.whatever;" at the beginning of the file, without putting the file in src/com/mycompany/whatever/MyClass.java then XDoclet won't process it. Right?

That's normal for XDoclet. You need to place your Java files in the appropriate directory for it's package.

Is that the problem?
legerdemain (10) [Avatar] Offline
#6
Re: Please help! Package statements still causing issue.
Thank you, thank you, thank you!!! smilie smilie smilie I knew it was undoubtedly some stupid oversight on my part. You hit the nail on the head! Sure enough that was EXACTLY the problem. Thank you so very much. I apologize for being such a pest, especially for something that turned out to be such a trivial problem.

And just for clarification, yes, you described it perfectly. I had my files in src/MyClass.java and the custom xdoclet tasks were in the root above the src directory. Once I put the files in the proper directory structure, everything worked beautifully. Thank you again, very much. And thanks for writing the book!
orb (16) [Avatar] Offline
#7
Re: Please help! Package statements still causing issue.
Glad to help. I hope you'll recommend the book to others. Amazon reviews are always highly appreciated too. smilie