You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Martin Richards <ma...@hawthornmedia.com.au> on 2004/07/09 00:54:18 UTC

Path not propagating correctly for subproject build files in javadoc task

I'm trying to organise a project as a master build file with global
tasks and properties and subproject build files that take care of tasks
specific to each subproject. The javac task works fine, but the javadoc
task is having problems with using the globally set path. I've
constructed a simple sample to demonstrate the problem:

Directory Structure

ant-javadoc-task-broken/
                +--------sub-project/
                |             +---------HelloWorld.java
                |             +---------sub-project-build.xml 
                +--------build.xml


build.xml contents:

<project name="ant-javadoc-task-broken" basedir="./" default="compile">
  
  <target name="init">
    <path id="project.classpath">
      <fileset dir=".">
        <include name="*.jar"/>
      </fileset>
    </path>    
  </target>
  
  <target name="compile" depends="init">
    <ant dir="sub-project" antfile="sub-project-build.xml"
target="compile"/>
  </target>

  <target name="javadoc" depends="init">
    <ant dir="sub-project" antfile="sub-project-build.xml"
target="doc"/>
  </target>  	
	
</project>    

sub-project-build.xml contents:

<project default="compile">
  
  <target name="init"> 
    <path id="sub-project.classpath">
      <path refid="project.classpath"/>
      <fileset dir=".">
        <include name="**/*.jar"/>
      </fileset>
    </path>
  </target>
  
  <target name="compile" depends="init">
    <javac destdir="." 
           srcdir=".">
	    <classpath refid="sub-project.classpath"/>
    </javac>
  </target>
    
  <target name="doc" depends="init">
    <javadoc packagenames="*"
             sourcepath="." 
             destdir=".">
      <classpath refid="sub-project.classpath"/>
    </javadoc>
  </target>  
</project>

HelloWorld.java contents:

public class HelloWorld {
    
    /**
     * main for hello world
     * @param args
     */
    public static void main(String[] args){
        System.out.println("Hello World");
    }
}

The compile task works fine, but the javadoc task breaks, and breaks
ugly, throwing an exception that seems to stem from a circular
reference. The references look straightforward and hierarchical to me.
The relevant part of the output from ant javadoc -debug is:

BUILD FAILED
D:\eclipse\workspace\ant-javadoc-task-broken\build.xml:16: Following
error occured while executing this line
D:\eclipse\workspace\ant-javadoc-task-broken\sub-project\sub-project-bui
ld.xml:22: Reference project.classpath not found
.
        at
org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHe
lper.java:537)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:385)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at
org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at org.apache.tools.ant.Main.runBuild(Main.java:632)
        at org.apache.tools.ant.Main.startAnt(Main.java:183)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
Caused by:
D:\eclipse\workspace\ant-javadoc-task-broken\sub-project\sub-project-bui
ld.xml:22: Reference project.classpat
h not found.
        at
org.apache.tools.ant.types.Reference.getReferencedObject(Reference.java:
56)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:460)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
        at org.apache.tools.ant.types.Path.list(Path.java:279)
        at org.apache.tools.ant.types.Path.addExisting(Path.java:245)
        at org.apache.tools.ant.types.Path.addExisting(Path.java:234)
        at
org.apache.tools.ant.types.Path.concatSystemClasspath(Path.java:547)
        at
org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1626)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
        ... 10 more
--- Nested Exception ---
D:\eclipse\workspace\ant-javadoc-task-broken\sub-project\sub-project-bui
ld.xml:22: Reference project.classpath not found
.
        at
org.apache.tools.ant.types.Reference.getReferencedObject(Reference.java:
56)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:460)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
        at
org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
        at org.apache.tools.ant.types.Path.list(Path.java:279)
        at org.apache.tools.ant.types.Path.addExisting(Path.java:245)
        at org.apache.tools.ant.types.Path.addExisting(Path.java:234)
        at
org.apache.tools.ant.types.Path.concatSystemClasspath(Path.java:547)
        at
org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1626)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
        at
org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
        at org.apache.tools.ant.Task.perform(Task.java:364)
        at org.apache.tools.ant.Target.execute(Target.java:301)
        at org.apache.tools.ant.Target.performTasks(Target.java:328)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
        at
org.apache.tools.ant.Project.executeTargets(Project.java:1063)
        at org.apache.tools.ant.Main.runBuild(Main.java:632)
        at org.apache.tools.ant.Main.startAnt(Main.java:183)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)

Having looked briefly through the source, javac and javadoc seem to be
using very different idioms to access the relevant Path objects, but I
haven't had the time to look into it any deeper, and I'm kind of hoping
I'm just missing something obvious or making some simple mistake in one
of my build files. Does anyone know of a solution? As a temporary hack
I'm copying the relevant path state from the global build file manually
into each sub-project build file, but this is exactly the kind of manual
process/coupling/poor cohesiveness I was looking to avoid. Thanks in
advance for any tips.



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Path not propagating correctly for subproject build files in javadoc task

Posted by Peter Reilly <pe...@corvil.com>.
Your <ant> task needs to have inheritrefs="yes", or have a nested
reference element specifing the "project.classpath" reference.

Peter
Martin Richards wrote:

>I'm trying to organise a project as a master build file with global
>tasks and properties and subproject build files that take care of tasks
>specific to each subproject. The javac task works fine, but the javadoc
>task is having problems with using the globally set path. I've
>constructed a simple sample to demonstrate the problem:
>
>Directory Structure
>
>ant-javadoc-task-broken/
>                +--------sub-project/
>                |             +---------HelloWorld.java
>                |             +---------sub-project-build.xml 
>                +--------build.xml
>
>
>build.xml contents:
>
><project name="ant-javadoc-task-broken" basedir="./" default="compile">
>  
>  <target name="init">
>    <path id="project.classpath">
>      <fileset dir=".">
>        <include name="*.jar"/>
>      </fileset>
>    </path>    
>  </target>
>  
>  <target name="compile" depends="init">
>    <ant dir="sub-project" antfile="sub-project-build.xml"
>target="compile"/>
>  </target>
>
>  <target name="javadoc" depends="init">
>    <ant dir="sub-project" antfile="sub-project-build.xml"
>target="doc"/>
>  </target>  	
>	
></project>    
>
>sub-project-build.xml contents:
>
><project default="compile">
>  
>  <target name="init"> 
>    <path id="sub-project.classpath">
>      <path refid="project.classpath"/>
>      <fileset dir=".">
>        <include name="**/*.jar"/>
>      </fileset>
>    </path>
>  </target>
>  
>  <target name="compile" depends="init">
>    <javac destdir="." 
>           srcdir=".">
>	    <classpath refid="sub-project.classpath"/>
>    </javac>
>  </target>
>    
>  <target name="doc" depends="init">
>    <javadoc packagenames="*"
>             sourcepath="." 
>             destdir=".">
>      <classpath refid="sub-project.classpath"/>
>    </javadoc>
>  </target>  
></project>
>
>HelloWorld.java contents:
>
>public class HelloWorld {
>    
>    /**
>     * main for hello world
>     * @param args
>     */
>    public static void main(String[] args){
>        System.out.println("Hello World");
>    }
>}
>
>The compile task works fine, but the javadoc task breaks, and breaks
>ugly, throwing an exception that seems to stem from a circular
>reference. The references look straightforward and hierarchical to me.
>The relevant part of the output from ant javadoc -debug is:
>
>BUILD FAILED
>D:\eclipse\workspace\ant-javadoc-task-broken\build.xml:16: Following
>error occured while executing this line
>D:\eclipse\workspace\ant-javadoc-task-broken\sub-project\sub-project-bui
>ld.xml:22: Reference project.classpath not found
>.
>        at
>org.apache.tools.ant.ProjectHelper.addLocationToBuildException(ProjectHe
>lper.java:537)
>        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:385)
>        at
>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
>        at org.apache.tools.ant.Task.perform(Task.java:364)
>        at org.apache.tools.ant.Target.execute(Target.java:301)
>        at org.apache.tools.ant.Target.performTasks(Target.java:328)
>        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
>        at
>org.apache.tools.ant.Project.executeTargets(Project.java:1063)
>        at org.apache.tools.ant.Main.runBuild(Main.java:632)
>        at org.apache.tools.ant.Main.startAnt(Main.java:183)
>        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
>        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
>Caused by:
>D:\eclipse\workspace\ant-javadoc-task-broken\sub-project\sub-project-bui
>ld.xml:22: Reference project.classpat
>h not found.
>        at
>org.apache.tools.ant.types.Reference.getReferencedObject(Reference.java:
>56)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:460)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
>        at org.apache.tools.ant.types.Path.list(Path.java:279)
>        at org.apache.tools.ant.types.Path.addExisting(Path.java:245)
>        at org.apache.tools.ant.types.Path.addExisting(Path.java:234)
>        at
>org.apache.tools.ant.types.Path.concatSystemClasspath(Path.java:547)
>        at
>org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1626)
>        at
>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
>        at org.apache.tools.ant.Task.perform(Task.java:364)
>        at org.apache.tools.ant.Target.execute(Target.java:301)
>        at org.apache.tools.ant.Target.performTasks(Target.java:328)
>        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
>        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
>        ... 10 more
>--- Nested Exception ---
>D:\eclipse\workspace\ant-javadoc-task-broken\sub-project\sub-project-bui
>ld.xml:22: Reference project.classpath not found
>.
>        at
>org.apache.tools.ant.types.Reference.getReferencedObject(Reference.java:
>56)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:460)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
>        at
>org.apache.tools.ant.types.Path.dieOnCircularReference(Path.java:468)
>        at org.apache.tools.ant.types.Path.list(Path.java:279)
>        at org.apache.tools.ant.types.Path.addExisting(Path.java:245)
>        at org.apache.tools.ant.types.Path.addExisting(Path.java:234)
>        at
>org.apache.tools.ant.types.Path.concatSystemClasspath(Path.java:547)
>        at
>org.apache.tools.ant.taskdefs.Javadoc.execute(Javadoc.java:1626)
>        at
>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
>        at org.apache.tools.ant.Task.perform(Task.java:364)
>        at org.apache.tools.ant.Target.execute(Target.java:301)
>        at org.apache.tools.ant.Target.performTasks(Target.java:328)
>        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
>        at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:383)
>        at
>org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:269)
>        at org.apache.tools.ant.Task.perform(Task.java:364)
>        at org.apache.tools.ant.Target.execute(Target.java:301)
>        at org.apache.tools.ant.Target.performTasks(Target.java:328)
>        at org.apache.tools.ant.Project.executeTarget(Project.java:1215)
>        at
>org.apache.tools.ant.Project.executeTargets(Project.java:1063)
>        at org.apache.tools.ant.Main.runBuild(Main.java:632)
>        at org.apache.tools.ant.Main.startAnt(Main.java:183)
>        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:197)
>        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:56)
>
>Having looked briefly through the source, javac and javadoc seem to be
>using very different idioms to access the relevant Path objects, but I
>haven't had the time to look into it any deeper, and I'm kind of hoping
>I'm just missing something obvious or making some simple mistake in one
>of my build files. Does anyone know of a solution? As a temporary hack
>I'm copying the relevant path state from the global build file manually
>into each sub-project build file, but this is exactly the kind of manual
>process/coupling/poor cohesiveness I was looking to avoid. Thanks in
>advance for any tips.
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
>For additional commands, e-mail: user-help@ant.apache.org
>
>
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org