User: ara_e_w 
  Date: 02/04/12 14:01:58

  Modified:    core/src/xdoclet DocletTask.java XmlSubTask.java
  Log:
  fork=false works fine :-)
  
  Revision  Changes    Path
  1.34      +180 -27   xdoclet/core/src/xdoclet/DocletTask.java
  
  Index: DocletTask.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/DocletTask.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -w -r1.33 -r1.34
  --- DocletTask.java   9 Apr 2002 00:07:16 -0000       1.33
  +++ DocletTask.java   12 Apr 2002 21:01:58 -0000      1.34
  @@ -7,24 +7,25 @@
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.DirectoryScanner;
   import org.apache.tools.ant.Task;
  -import org.apache.tools.ant.taskdefs.Javadoc;
  +import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.types.Reference;
   import org.apache.log4j.Category;
   
  -import xdoclet.template.TemplateException;
  -import xdoclet.template.TemplateEngine;
  -import xdoclet.util.Log;
   import xdoclet.util.Translator;
  +import xdoclet.util.XmlValidator;
  +import xdoclet.util.Log;
  +import xdoclet.template.TemplateException;
   
  -import xjavadoc.ant.XJavadocTask;
  +import xjavadoc.SourceSet;
  +import xjavadoc.XJavaDoc;
   
   import java.io.*;
   import java.util.HashMap;
   import java.util.List;
   import java.util.ArrayList;
  -import java.beans.Introspector;
  +import java.util.Vector;
   
   /**
    * A base class for all Tasks. It can also be used directly, useful for the case
  @@ -34,9 +35,9 @@
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @author    <a href="mailto:[EMAIL PROTECTED]";>Aslak Helles�y</a>
    * @created   June 19, 2001
  - * @version   $Revision: 1.33 $
  + * @version   $Revision: 1.34 $
    */
  -public class DocletTask extends XJavadocTask
  +public class DocletTask extends Task
   {
        // ant will replace the tag with the version propperty specified in build.xml
        /**
  @@ -47,19 +48,21 @@
        /**
         * @todo-javadoc   Describe the field
         */
  -     private final static String fileName = "xdoclet." + System.getProperty( 
"user.name" ) + ".ser";
  +     protected transient DocletContext context = null;
  +
        /**
         * @todo-javadoc   Describe the field
         */
  -     private final static File DEFAULT_TMP_FILE = new File( System.getProperty( 
"java.io.tmpdir" ), fileName );
  +     private final Vector filesets = new Vector();
  +
        /**
         * @todo-javadoc   Describe the field
         */
  -     private static File _tmpFile = DEFAULT_TMP_FILE;
  +     private Path       classpath;
        /**
         * @todo-javadoc   Describe the field
         */
  -     protected transient DocletContext context = null;
  +     private Reference  classpathRef;
   
        /**
         * @todo-javadoc   Describe the field
  @@ -90,15 +93,23 @@
        private ArrayList  configParams = new ArrayList();
   
        /**
  -      * Describe what the DocletTask constructor does
  +      * Gets the Classpath attribute of the DocletTask object
  +      *
  +      * @return   The Classpath value
  +      */
  +     public Path getClasspath()
  +     {
  +             return classpath;
  +     }
  +
  +     /**
  +      * Gets the ClasspathRef attribute of the DocletTask object
         *
  -      * @todo-javadoc   Write javadocs for constructor
  +      * @return   The ClasspathRef value
         */
  -     public DocletTask()
  +     public Reference getClasspathRef()
        {
  -             setClassname( "xdoclet.XDocletMain" );
  -             // fork is default
  -             setFork( true );
  +             return classpathRef;
        }
   
        /**
  @@ -162,6 +173,34 @@
        }
   
        /**
  +      * Sets the Classpath attribute of the DocletTask object
  +      *
  +      * @param src  The new Classpath value
  +      */
  +     public void setClasspath( Path src )
  +     {
  +             if( classpath == null )
  +             {
  +                     classpath = src;
  +             }
  +             else
  +             {
  +                     classpath.append( src );
  +             }
  +     }
  +
  +     /**
  +      * Sets the ClasspathRef attribute of the DocletTask object
  +      *
  +      * @param ref  The new ClasspathRef value
  +      */
  +     public void setClasspathRef( org.apache.tools.ant.types.Reference ref )
  +     {
  +             this.classpathRef = ref;
  +             createClasspath().setRefid( ref );
  +     }
  +
  +     /**
         * Sets the Sourcepath attribute of the DocletTask object
         *
         * @param path  The new Sourcepath value
  @@ -238,13 +277,32 @@
        }
   
        /**
  -      * Sets the Xdoclettempfile attribute of the DocletTask object
  +      * Describe what the method does
  +      *
  +      * @return         Describe the return value
  +      * @todo-javadoc   Write javadocs for method
  +      * @todo-javadoc   Write javadocs for return value
  +      */
  +     public Path createClasspath()
  +     {
  +             if( classpath == null )
  +             {
  +                     classpath = new Path( project );
  +             }
  +
  +             return classpath.createPath();
  +     }
  +
  +     /**
  +      * Describe the method
         *
  -      * @param tmpFile  The new Xdoclettempfile value
  +      * @param set      Describe the method parameter
  +      * @todo-javadoc   Describe the method
  +      * @todo-javadoc   Describe the method parameter
         */
  -     public void setXdoclettempfile( File tmpFile )
  +     public void addFileset( FileSet set )
        {
  -             _tmpFile = tmpFile;
  +             filesets.addElement( set );
        }
   
        /**
  @@ -294,12 +352,33 @@
        {
                try
                {
  +                     AntClassLoader loader = new AntClassLoader( project, classpath 
);
  +
  +                     XJavaDoc.getInstance().setClassLoader( loader );
  +                     XmlValidator.setInstance( new XmlValidator( loader ) );
  +
                        // save the context and pass its filename as an arg to the main
  -                     save( getContext(), _tmpFile );
  -                     createArg().setValue( _tmpFile.getAbsolutePath() );
  -                     super.execute();
  +                     SourceSet[] sourceSets = new SourceSet[filesets.size()];
  +
  +                     for( int i = 0; i < filesets.size(); i++ )
  +                     {
  +                             FileSet fs = ( FileSet ) filesets.elementAt( i );
  +                             File dir = fs.getDir( project );
  +
  +                             DirectoryScanner ds = fs.getDirectoryScanner( project 
);
  +                             String[] files = ds.getIncludedFiles();
  +
  +                             sourceSets[i] = new SourceSet( dir, files );
  +                     }
  +
  +                     for( int i = 0; i < sourceSets.length; i++ )
  +                     {
  +                             XJavaDoc.getInstance().addSourceSet( sourceSets[i] );
  +                     }
  +
  +                     executeSubTasks();
                }
  -             catch( IOException e )
  +             catch( Exception e )
                {
                        e.printStackTrace();
                        throw new BuildException( e );
  @@ -447,12 +526,21 @@
         */
        protected void validateOptions() throws BuildException
        {
  -             super.validateOptions();
  +             if( filesets.size() == 0 )
  +             {
  +                     throw new BuildException( "At least one fileset must be 
specified", location );
  +             }
  +
                if( destDir == null )
                {
                        throw new BuildException( Translator.getString( 
"attribute_not_present_error", new String[]{"destDir"} ), location );
                }
   
  +             if( classpath == null )
  +             {
  +                     classpath = org.apache.tools.ant.types.Path.systemClasspath;
  +             }
  +
                validateSubTasks();
        }
   
  @@ -481,6 +569,71 @@
                                catch( XDocletException ex )
                                {
                                        new BuildException( subtask.getSubTaskName() + 
": " + ex.getMessage(), location );
  +                             }
  +                     }
  +             }
  +     }
  +
  +     /**
  +      * Describe what the method does
  +      *
  +      * @todo-javadoc   Write javadocs for method
  +      */
  +     private void executeSubTasks()
  +     {
  +             Category cat = Log.getCategory( DocletTask.class, "executeSubTasks" );
  +
  +             DocletContext context = getContext();
  +             SubTask[] subtasks = context.getSubTasks();
  +
  +             for( int i = 0; i < subtasks.length; i++ )
  +             {
  +                     SubTask subtask = subtasks[i];
  +
  +                     if( subtask != null )
  +                     {
  +                             if( cat.isDebugEnabled() )
  +                             {
  +                                     cat.debug( "SubTask " + 
subtasks[i].getSubTaskName() + "Initialized." );
  +                             }
  +
  +                             try
  +                             {
  +                                     subtasks[i].init();
  +                                     DocletContext.getInstance().setActiveSubTask( 
subtasks[i] );
  +
  +                                     System.out.println( Translator.getString( 
"running_taskname", new String[]{"<" + subtasks[i].getSubTaskName() + "/>"} ) );
  +                                     subtasks[i].execute();
  +                             }
  +                             catch( XDocletException e )
  +                             {
  +                                     System.out.println( Translator.getString( 
"running_failed" ) );
  +                                     System.out.println( "<<" + e.getMessage() + 
">>" );
  +
  +                                     if( e.getNestedException() != null )
  +                                     {
  +                                             
e.getNestedException().printStackTrace();
  +                                     }
  +
  +                                     if( e.getNestedException() instanceof 
TemplateException )
  +                                     {
  +                                             TemplateException template_ex = ( 
TemplateException ) e.getNestedException();
  +
  +                                             if( cat.isDebugEnabled() )
  +                                             {
  +                                                     cat.error( "Template Exception 
= " + template_ex );
  +                                                     cat.error( "Nested Exception = 
" + template_ex.getNestedException() );
  +                                             }
  +                                     }
  +
  +                                     if( cat.isDebugEnabled() )
  +                                     {
  +                                             cat.error( "Exception trace:\n" + 
e.getPrintStackTrace() );
  +                                     }
  +
  +                                     e.printStackTrace();
  +                                     throw new BuildException( e.getMessage(), e, 
location );
  +                                     //return false;
                                }
                        }
                }
  
  
  
  1.13      +3 -8      xdoclet/core/src/xdoclet/XmlSubTask.java
  
  Index: XmlSubTask.java
  ===================================================================
  RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/XmlSubTask.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -w -r1.12 -r1.13
  --- XmlSubTask.java   7 Apr 2002 11:24:10 -0000       1.12
  +++ XmlSubTask.java   12 Apr 2002 21:01:58 -0000      1.13
  @@ -12,18 +12,13 @@
   /**
    * @author    Ara Abrahamian ([EMAIL PROTECTED])
    * @created   Oct 13, 2001
  - * @version   $Revision: 1.12 $
  + * @version   $Revision: 1.13 $
    */
   public class XmlSubTask extends TemplateSubTask
   {
        /**
         * @todo-javadoc   Describe the field
         */
  -     private final static XmlValidator xmlValidator = new XmlValidator();
  -
  -     /**
  -      * @todo-javadoc   Describe the field
  -      */
        private boolean    useIds = false;
        /**
         * @todo-javadoc   Describe the field
  @@ -234,7 +229,7 @@
   
                if( shouldValidate() )
                {
  -                     xmlValidator.registerDTD( getPublicId(), getDtdFileName() );
  +                     XmlValidator.getInstance().registerDTD( getPublicId(), 
getDtdFileName() );
                }
   
                //reset ids counter
  @@ -261,7 +256,7 @@
   
                if( shouldValidate() )
                {
  -                     xmlValidator.validate( getEngine().getOutput() );
  +                     XmlValidator.getInstance().validate( getEngine().getOutput() );
                }
        }
   
  
  
  

_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel

Reply via email to