jvanzyl     02/04/18 10:43:35

  Modified:    .        build.xml
               src/java/org/apache/maven Jxr.java
               src/java/org/apache/maven/jxr CodeTransform.java JXR.java
               src/templates/build Control.vm build-docs.xml build.xml
                        default.properties
               xdocs    powered.xml
  Log:
  Apply patch submitted by Brian Leonard <[EMAIL PROTECTED]>:
  
  it makes jxr more like the javadoc task, such that you can use src.set or
  src.dir.  it xrefs into the same directory hierarchy as javadocs to make
  linking saner
  
  makes jxr use the ${javadoc.destdir} property.  before it was just
  
  assuming javadocs were in a specific directory.
  adds a jxr.destdir property
  
  Revision  Changes    Path
  1.26      +5 -0      jakarta-turbine-maven/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/build.xml,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- build.xml 16 Apr 2002 18:17:35 -0000      1.25
  +++ build.xml 18 Apr 2002 17:43:34 -0000      1.26
  @@ -165,6 +165,11 @@
         <ant antfile="${maven.home}/build-docs.xml" target="generate-xdocs"/>
       </target>
   
  +    <target 
  +      name="maven:generate-reactor">
  +      <ant antfile="${maven.home}/build-reactor.xml" target="generate-reactor"/>
  +    </target>
  +
     <!-- maven:end -->
   
   </project>
  
  
  
  1.2       +161 -15   jakarta-turbine-maven/src/java/org/apache/maven/Jxr.java
  
  Index: Jxr.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/Jxr.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Jxr.java  28 Feb 2002 22:41:02 -0000      1.1
  +++ Jxr.java  18 Apr 2002 17:43:34 -0000      1.2
  @@ -57,6 +57,14 @@
   import org.apache.maven.jxr.*;
   import org.apache.maven.jxr.pacman.PackageManager;
   import org.apache.maven.executor.AbstractExecutor;
  +import org.apache.tools.ant.types.Reference;
  +import org.apache.tools.ant.types.Path;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.Task;
  +import org.apache.tools.ant.BuildException;
  +import java.util.LinkedList;
  +import java.io.File;
  +import java.io.IOException;
   
   /**
    * Creates an html-based, cross referenced  version of Java source code
  @@ -64,22 +72,32 @@
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Josh Lucas</a>
    * @author <a href="mailto:[EMAIL PROTECTED]";>Jason van Zyl</a>
  - * @version $Id: Jxr.java,v 1.1 2002/02/28 22:41:02 jvanzyl Exp $
  + * @version $Id: Jxr.java,v 1.2 2002/04/18 17:43:34 jvanzyl Exp $
    */
   public class Jxr
       extends AbstractExecutor
   {
       /**
  -     * the starting directory housing the .java files
  +     * Directories to be cross-referenced
        */
  -    private String startDir;
  +    private Path sourcePath;
   
       /**
  +     * Reference object contatining multiple paths to be cross-referenced
  +     */
  +    private Reference ref;
  +    
  +    /**
        * the destination directory
        */
       private String destDir;
   
       /**
  +     * Root javadocs directory
  +     */
  +    private String javadocDir;
  +
  +    /**
        * the location of the folder.gif
        */
       private String imageFolder;
  @@ -89,23 +107,124 @@
        */
       private String imageFile;
   
  +
       /**
  -     * Description of the Method
  +     * Starts the cross-referencing and indexing.
        */
       public void execute()
  -        throws Exception
  +        throws BuildException
       {
  +        // ant's TaskAdapter doesn't set the Project until this method, so
  +        // figure out which path to use here. 
  +        if (sourcePath == null)
  +        {
  +            if (ref != null)
  +            {
  +                sourcePath = new Path(getProject());
  +                sourcePath.createPath().setRefid(ref);
  +            }
  +            else
  +            {
  +                String err = "Must specify either sourcePathRef or sourcePath";
  +                throw new BuildException(err);
  +            }
  +        }
  +
  +        // get a relative link to the javadocs
  +        String javadocLinkDir = null;
  +        try
  +        {
  +            javadocLinkDir = getRelativeLink(destDir, javadocDir);
  +        }
  +        catch (IOException ioe)
  +        {
  +            throw new BuildException("Error finding javadocs", ioe);
  +        }
  +        
  +        // go through each source directory and xref the java files
           PackageManager pkgmgr = PackageManager.getInstance();
  -        pkgmgr.process(startDir);
  -
  -        // It is certainly not clear what's going on here. I believe we
  -        // have some in-memory work going on and then the results of the
  -        // work are placed in 'destDir' by the DirectoryIndexer.
  -        new JXR(startDir, destDir, "HEAD");
  -        new DirectoryIndexer(destDir, imageFolder, imageFile, 
DirectoryIndexer.MODE_JAVA);
  +        String[] paths = sourcePath.list();
  +        for (int i = 0; i < paths.length; ++i)
  +        {
  +            pkgmgr.process(paths[i]);
  +
  +            new JXR(paths[i], destDir, javadocLinkDir, "HEAD");
  +        }
  +
  +        // once we have all the source files xref'd, create the index pages
  +        try
  +        {
  +            new DirectoryIndexer(destDir, imageFolder, imageFile,
  +                                 DirectoryIndexer.MODE_JAVA);
  +        }
  +        catch (IOException ioe)
  +        {
  +            throw new BuildException(ioe);
  +        }
       }
   
       /**
  +     * Creates a relative link from one directory to another.
  +     *
  +     * Example:
  +     *   given /foo/bar/baz/oink
  +     *     and /foo/bar/schmoo
  +     *
  +     * this method will return a string of "../../schmoo/"
  +     *
  +     * @param fromDir The directory from which the link is relative.
  +     * @param toDir   The directory into which the link points.
  +     * @throws IOException
  +     *    If a problem is encountered while navigating through the directories.
  +     */
  +    private String getRelativeLink(String fromDir, String toDir)
  +        throws IOException
  +    {
  +        StringBuffer toLink = new StringBuffer();   // up from fromDir
  +        StringBuffer fromLink = new StringBuffer(); // down into toDir
  +
  +        // assume they are both at least rooted at the project's baseDir
  +        File baseDir = new File(getProject().getBaseDir().getCanonicalPath());
  +
  +        // create a List of toDir's parent directories
  +        LinkedList parents = new LinkedList();
  +        File f = new File(new File(javadocDir).getCanonicalPath());
  +        while (f != null && !f.equals(baseDir))
  +        {
  +            parents.add(f);
  +            f = new File(f.getParent());
  +        }
  +            
  +        // walk up fromDir to find the common parent
  +        f = new File(new File(destDir).getCanonicalPath());
  +        f = new File(f.getParent());
  +        boolean found = false;
  +        while (f != null && !found && !f.equals(baseDir))
  +        {
  +            for (int i = 0; i < parents.size(); ++i)
  +            {
  +                File parent = (File)parents.get(i);
  +                if (f.equals(parent))
  +                {
  +                    // when we find the common parent, add the subdirectories 
  +                    // down to toDir itself
  +                    for (int j = 0; j < i; ++j)
  +                    {
  +                        File p = (File)parents.get(j);
  +                        toLink.insert(0, p.getName() + "/");
  +                    }
  +                    found = true;
  +                    break;
  +                }
  +            }
  +            f = new File(f.getParent());
  +            fromLink.append("../");
  +        }
  +
  +        return fromLink.append(toLink).toString();
  +    }
  +    
  +    /**
        * Sets the imageFile attribute of the JxrTask object
        */
       public void setImageFile(String imageFile)
  @@ -122,11 +241,29 @@
       }
   
       /**
  -     * Sets the startDir attribute of the JxrTask object
  +     * Sets the source path to a single path, or
  +     * appends onto the existing source path.
  +     * @param src The source directory to be cross-referenced.
  +     */
  +    public void setSourcepath(Path src)
  +    {
  +        if (sourcePath == null)
  +        {
  +            sourcePath = src;
  +        }
  +        else
  +        {
  +            sourcePath.append(src);
  +        }
  +    }
  +        
  +    /**
  +     * Sets the source path to a reference object
  +     * @param ref The Reference object containing paths to be cross-referenced.
        */
  -    public void setStartDir(String startDir)
  +    public void setSourcepathref(Reference ref)
       {
  -        this.startDir = startDir;
  +        this.ref = ref;
       }
   
       /**
  @@ -135,6 +272,15 @@
       public void setDestDir(String destDir)
       {
           this.destDir = destDir;
  +    }
  +
  +    /**
  +     * Sets the javadocDir attribute of the JxrTask object
  +     * @param javadocDir The root directory containing javadocs
  +     */
  +    public void setJavadocDir(String javadocDir)
  +    {
  +        this.javadocDir = javadocDir;
       }
   }
   
  
  
  
  1.10      +8 -2      
jakarta-turbine-maven/src/java/org/apache/maven/jxr/CodeTransform.java
  
  Index: CodeTransform.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jxr/CodeTransform.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CodeTransform.java        27 Mar 2002 20:44:15 -0000      1.9
  +++ CodeTransform.java        18 Apr 2002 17:43:34 -0000      1.10
  @@ -169,6 +169,11 @@
        */
       private String sourcedir = null;
   
  +    /**
  +     * Relative path to javadocs, suitable for hyperlinking
  +     */
  +    private String javadocLinkDir;
  +    
   
       /**
        * Constructor for the CodeTransform object
  @@ -591,6 +596,7 @@
        */
       public final void transform(String sourcefile,
                                   String destfile,
  +                                String javadocLinkDir,
                                   String revision)
           throws IOException
       {
  @@ -599,6 +605,7 @@
   
           this.sourcefile = sourcefile;
           this.destfile = destfile;
  +        this.javadocLinkDir = javadocLinkDir;
           this.revision = revision;
   
           //make sure that the parent directories exist...
  @@ -645,13 +652,12 @@
           //get the URI to get Javadoc info.
           StringBuffer javadocURI = new StringBuffer()
               .append(getPackageRoot())
  -            .append("../../apidocs");
  +            .append(javadocLinkDir);
   
           try
           {
               JavaFile jf = 
FileManager.getInstance().getFile(this.getCurrentFilename());
   
  -            javadocURI.append("/");
               javadocURI.append(Strings.replace(jf.getPackageType().getName(), ".", 
"/"));
               javadocURI.append("/");
               if (jf.getClassType() != null)
  
  
  
  1.9       +9 -2      jakarta-turbine-maven/src/java/org/apache/maven/jxr/JXR.java
  
  Index: JXR.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/java/org/apache/maven/jxr/JXR.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- JXR.java  28 Feb 2002 22:29:01 -0000      1.8
  +++ JXR.java  18 Apr 2002 17:43:34 -0000      1.9
  @@ -63,7 +63,7 @@
    * Main entry point into Maven used to kick off the XReference code building.
    *
    * @author <a href="mailto:[EMAIL PROTECTED]";>Kevin A. Burton</a>
  - * @version $Id: JXR.java,v 1.8 2002/02/28 22:29:01 jvanzyl Exp $
  + * @version $Id: JXR.java,v 1.9 2002/04/18 17:43:34 jvanzyl Exp $
    */
   public class JXR
   {
  @@ -84,6 +84,11 @@
       private String dest = "";
   
       /**
  +     * Relative path to javadocs, suitable for hyperlinking
  +     */
  +    private String javadocLinkDir;
  +    
  +    /**
        * Handles taking .java files and changing them into html. "More than meets
        * the eye!" :)
        */
  @@ -104,10 +109,12 @@
        */
       public JXR(String source,
                  String dest,
  +               String javadocLinkDir,
                  String revision)
       {
           this.source = source;
           this.dest = dest;
  +        this.javadocLinkDir = javadocLinkDir;
           this.revision = revision;
   
           this.process();
  @@ -242,7 +249,7 @@
   
           log(source + " -> " + dest);
   
  -        transformer.transform(source, dest, this.revision);
  +        transformer.transform(source, dest, javadocLinkDir, this.revision);
   
       }
   
  
  
  
  1.14      +1 -0      jakarta-turbine-maven/src/templates/build/Control.vm
  
  Index: Control.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/Control.vm,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Control.vm        18 Apr 2002 13:03:38 -0000      1.13
  +++ Control.vm        18 Apr 2002 17:43:34 -0000      1.14
  @@ -7,6 +7,7 @@
   $buildElements.add("build-test.xml")
   $buildElements.add("build-iutest.xml")
   $buildElements.add("build-maven.xml")
  +$buildElements.add("build-reactor.xml")
   $buildElements.add("default.properties")
   
   ## -------------------------------------------------------
  
  
  
  1.52      +4 -3      jakarta-turbine-maven/src/templates/build/build-docs.xml
  
  Index: build-docs.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build-docs.xml,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- build-docs.xml    18 Apr 2002 14:30:30 -0000      1.51
  +++ build-docs.xml    18 Apr 2002 17:43:34 -0000      1.52
  @@ -17,8 +17,8 @@
       <mkdir dir="${docs.src}/images"/>
       <mkdir dir="${docs.src}/stylesheets"/>
       <mkdir dir="${docs.dest}"/>
  -    <mkdir dir="${docs.dest}/xref"/>
       <mkdir dir="${gen.docs}"/>
  +    <mkdir dir="${jxr.destdir}"/>
       <mkdir dir="${javadoc.destdir}"/>
   
     </target>
  @@ -61,8 +61,9 @@
       <echo>${sourcesPresent}</echo>
   
       <jxr
  -      startDir="${src.dir}"
  -      destDir="${docs.dest}/xref"
  +      sourcepathref="src.set"
  +      destDir="${jxr.destdir}"
  +      javadocDir="${javadoc.destdir}"
         imageFolder="${maven.home}/images/folder.gif"
         imageFile="${maven.home}/images/file.gif">
       </jxr>
  
  
  
  1.28      +5 -0      jakarta-turbine-maven/src/templates/build/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/build.xml,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- build.xml 17 Apr 2002 22:56:31 -0000      1.27
  +++ build.xml 18 Apr 2002 17:43:34 -0000      1.28
  @@ -122,6 +122,11 @@
         <ant antfile="$mavenDirectory/build-docs.xml" target="generate-xdocs"/>
       </target>
   
  +    <target 
  +      name="maven:generate-reactor">
  +      <ant antfile="$mavenDirectory/build-reactor.xml" target="generate-reactor"/>
  +    </target>
  +
     <!-- maven:end -->
   
   </project>
  
  
  
  1.21      +5 -0      jakarta-turbine-maven/src/templates/build/default.properties
  
  Index: default.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/src/templates/build/default.properties,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- default.properties        18 Apr 2002 13:03:38 -0000      1.20
  +++ default.properties        18 Apr 2002 17:43:34 -0000      1.21
  @@ -57,6 +57,11 @@
   javadoc.use = true
   
   ##
  +# properties for jxr cross-referencing
  +##
  +jxr.destdir = ${docs.dest}/xref
  +
  +##
   # Checkstyle settings ... default maven settings, these can be
   # overridden in a project specific properties file.
   ##
  
  
  
  1.8       +23 -17    jakarta-turbine-maven/xdocs/powered.xml
  
  Index: powered.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-maven/xdocs/powered.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- powered.xml       9 Apr 2002 21:10:57 -0000       1.7
  +++ powered.xml       18 Apr 2002 17:43:35 -0000      1.8
  @@ -25,22 +25,27 @@
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/turbine/";>Turbine</a></td>
  +          <td><a href="http://jakarta.apache.org/turbine/fulcrum/";>Fulcrum</a></td>
             <td>
  -            A collection of projects dedicated to the development of web
  -            applications using a model-view-controller model.
  +            A services framework that was decoupled from Turbine.
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/turbine/turbine-2/";>Turbine 
2</a></td>
  +          <td><a href="http://jakarta.apache.org/jetspeed/";>Jetspeed</a></td>
             <td>
  -            Version 2 of the Turbine model-view-controller framework.
  +            Portal Framework.
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/turbine/turbine-3/";>Turbine 
3</a></td>
  +          <td><a href="http://jakarta.apache.org/commons/latka/";>Latka</a></td>
             <td>
  -            Version 3 of the Turbine model-view-controller framework.
  +            Latka is a functional (end to end) testing tool.
  +          </td>
  +        </tr>
  +        <tr>
  +          <td><a href="http://objectbridge.sf.net/";>ObjectBridge</a></td>
  +          <td>
  +            Persistence Layer.
             </td>
           </tr>
           <tr>
  @@ -50,9 +55,10 @@
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/turbine/fulcrum/";>Fulcrum</a></td>
  +          <td><a href="http://jakarta.apache.org/turbine/";>Turbine</a></td>
             <td>
  -            A services framework that was decoupled from Turbine.
  +            A collection of projects dedicated to the development of web
  +            applications using a model-view-controller model.
             </td>
           </tr>
           <tr>
  @@ -62,27 +68,27 @@
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/turbine/maven/";>Maven</a></td>
  +          <td><a href="http://jakarta.apache.org/turbine/turbine-2/";>Turbine 
2</a></td>
             <td>
  -            The future of all projects!
  +            Version 2 of the Turbine model-view-controller framework.
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/commons/latka/";>Latka</a></td>
  +          <td><a href="http://jakarta.apache.org/turbine/turbine-3/";>Turbine 
3</a></td>
             <td>
  -            Latka is a functional (end to end) testing tool.
  +            Version 3 of the Turbine model-view-controller framework.
             </td>
           </tr>
           <tr>
  -          <td><a href="http://quilt.sourceforge.net/";>Quilt</a></td>
  +          <td><a href="http://jakarta.apache.org/turbine/maven/";>Maven</a></td>
             <td>
  -            Test coverage tool.
  +            The future of all projects!
             </td>
           </tr>
           <tr>
  -          <td><a href="http://jakarta.apache.org/jetspeed/";>Jetspeed</a></td>
  +          <td><a href="http://quilt.sourceforge.net/";>Quilt</a></td>
             <td>
  -            Portal Framework.
  +            Test coverage tool.
             </td>
           </tr>
         </table>
  
  
  


Reply via email to