User: vharcq
Date: 02/04/16 13:36:48
Modified: core/src/xdoclet DocletTask.java
Log:
Add the call to reset() on XJavaDoc when beginning : we have to rset the SourceSet
hashset to empty
Revision Changes Path
1.36 +323 -333 xdoclet/core/src/xdoclet/DocletTask.java
Index: DocletTask.java
===================================================================
RCS file: /cvsroot/xdoclet/xdoclet/core/src/xdoclet/DocletTask.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -w -r1.35 -r1.36
--- DocletTask.java 14 Apr 2002 16:58:18 -0000 1.35
+++ DocletTask.java 16 Apr 2002 20:36:48 -0000 1.36
@@ -1,6 +1,37 @@
/*
- * Copyright (c) 2001,2002 The XDoclet team
+ * Copyright (c) 2001, Aslak Helles�y, BEKK Consulting
* All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification,
+ * are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of BEKK Consulting nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR
+ * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/*
+ * Change log
+ *
*/
package xdoclet;
@@ -35,15 +66,9 @@
* @author Ara Abrahamian ([EMAIL PROTECTED])
* @author <a href="mailto:[EMAIL PROTECTED]">Aslak Helles�y</a>
* @created June 19, 2001
- * @version $Revision: 1.35 $
+ * @version $Revision: 1.36 $
*/
-public class DocletTask extends Task
-{
- // ant will replace the tag with the version propperty specified in build.xml
- /**
- * @todo-javadoc Describe the field
- */
- public final static String XDOCLET_VERSION = "@VERSION@";
+public class DocletTask extends Task {
/**
* @todo-javadoc Describe the field
@@ -91,122 +116,45 @@
* @todo-javadoc Describe the field
*/
private ArrayList configParams = new ArrayList();
-
- /**
- * 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
- *
- * @return The ClasspathRef value
- */
- public Reference getClasspathRef()
- {
- return classpathRef;
- }
-
- /**
- * Gets the ConfigParams attribute of the DocletTask object
- *
- * @return The ConfigParams value
- */
- public ArrayList getConfigParams()
- {
- return configParams;
- }
-
- /**
- * Gets the MergeDir attribute of the DocletTask object
- *
- * @return The MergeDir value
- */
- public File getMergeDir()
- {
- return mergeDir;
- }
-
- /**
- * Gets the ExcludedTags attribute of the DocletTask object
- *
- * @return The ExcludedTags value
- */
- public String getExcludedTags()
- {
- return excludedTags;
- }
-
- /**
- * Gets the Templates attribute of the DocletTask object
- *
- * @return The Templates value
- */
- public ArrayList getTemplates()
- {
- return templates;
- }
-
+ // ant will replace the tag with the version propperty specified in build.xml
/**
- * Gets the DestDir attribute of the DocletTask object
- *
- * @return The DestDir value
+ * @todo-javadoc Describe the field
*/
- public File getDestDir()
- {
- return destDir;
- }
+ public final static String XDOCLET_VERSION = "@VERSION@";
- /**
- * Gets the Force attribute of the DocletTask object
- *
- * @return The Force value
- */
- public boolean isForce()
- {
- return force;
- }
/**
* Sets the Classpath attribute of the DocletTask object
*
* @param src The new Classpath value
*/
- public void setClasspath( Path src )
- {
- if( classpath == null )
- {
+ public void setClasspath(Path src) {
+ if (classpath == null) {
classpath = src;
}
- else
- {
+ 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 )
- {
+ 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
*/
- public void setSourcepath( Path path )
- {
+ public void setSourcepath(Path path) {
System.out.println( "sourcepath is deprecated. the preferred way to
design sources is via nested <fileset>" );
String dir = path.toString();
@@ -216,66 +164,147 @@
fileSet.setIncludes( "**/*.java" );
}
+
/**
* Sets the PackageNames attribute of the DocletTask object
*
* @param src The new PackageNames value
*/
- public void setPackageNames( String src )
- {
+ public void setPackageNames(String src) {
throw new BuildException( "packageNames is obsolete since xjavadoc was
introduced. Use a fileset instead" );
}
+
/**
* Sets the ExcludePackageNames attribute of the DocletTask object
*
* @param src The new ExcludePackageNames value
*/
- public void setExcludePackageNames( String src )
- {
+ public void setExcludePackageNames(String src) {
throw new BuildException( "excludePackageNames is obsolete since
xjavadoc was introduced. Use a fileset instead" );
}
+
/**
* Sets the ExcludedTags attribute of the DocletTask object
*
* @param tags The new ExcludedTags value
*/
- public void setExcludedTags( String tags )
- {
+ public void setExcludedTags(String tags) {
excludedTags = tags;
}
+
/**
* Sets the DestDir attribute of the DocletTask object
*
* @param dir The new DestDir value
*/
- public void setDestDir( File dir )
- {
+ public void setDestDir(File dir) {
destDir = dir;
}
+
/**
* Sets the MergeDir attribute of the DocletTask object
*
* @param dir The new MergeDir value
*/
- public void setMergeDir( File dir )
- {
+ public void setMergeDir(File dir) {
mergeDir = dir;
}
+
/**
* Sets the Force attribute of the DocletTask object
*
* @param force The new Force value
*/
- public void setForce( boolean force )
- {
+ public void setForce(boolean force) {
this.force = force;
}
+
+ /**
+ * 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
+ *
+ * @return The ClasspathRef value
+ */
+ public Reference getClasspathRef() {
+ return classpathRef;
+ }
+
+
+ /**
+ * Gets the ConfigParams attribute of the DocletTask object
+ *
+ * @return The ConfigParams value
+ */
+ public ArrayList getConfigParams() {
+ return configParams;
+ }
+
+
+ /**
+ * Gets the MergeDir attribute of the DocletTask object
+ *
+ * @return The MergeDir value
+ */
+ public File getMergeDir() {
+ return mergeDir;
+ }
+
+
+ /**
+ * Gets the ExcludedTags attribute of the DocletTask object
+ *
+ * @return The ExcludedTags value
+ */
+ public String getExcludedTags() {
+ return excludedTags;
+ }
+
+
+ /**
+ * Gets the Templates attribute of the DocletTask object
+ *
+ * @return The Templates value
+ */
+ public ArrayList getTemplates() {
+ return templates;
+ }
+
+
+ /**
+ * Gets the DestDir attribute of the DocletTask object
+ *
+ * @return The DestDir value
+ */
+ public File getDestDir() {
+ return destDir;
+ }
+
+
+ /**
+ * Gets the Force attribute of the DocletTask object
+ *
+ * @return The Force value
+ */
+ public boolean isForce() {
+ return force;
+ }
+
+
/**
* Describe what the method does
*
@@ -283,16 +312,15 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for return value
*/
- public Path createClasspath()
- {
- if( classpath == null )
- {
+ public Path createClasspath() {
+ if (classpath == null) {
classpath = new Path( project );
}
return classpath.createPath();
}
+
/**
* Describe the method
*
@@ -300,11 +328,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addFileset( FileSet set )
- {
+ public void addFileset(FileSet set) {
filesets.addElement( set );
}
+
/**
* Describe the method
*
@@ -312,11 +340,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addTemplate( TemplateSubTask subtask )
- {
+ public void addTemplate(TemplateSubTask subtask) {
templates.add( subtask );
}
+
/**
* Describe the method
*
@@ -324,11 +352,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addXmlTemplate( XmlSubTask subtask )
- {
+ public void addXmlTemplate(XmlSubTask subtask) {
templates.add( subtask );
}
+
/**
* Describe the method
*
@@ -336,11 +364,11 @@
* @todo-javadoc Describe the method
* @todo-javadoc Describe the method parameter
*/
- public void addConfigParam( ConfigParameter config_param )
- {
+ public void addConfigParam(ConfigParameter config_param) {
configParams.add( config_param );
}
+
/**
* Describe what the method does
*
@@ -348,64 +376,56 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- public void execute() throws BuildException
- {
- try
- {
+ public void execute() throws BuildException {
+ try {
AntClassLoader loader = new AntClassLoader( project, classpath
);
+ XJavaDoc.getInstance().reset();
XJavaDoc.getInstance().setClassLoader( loader );
XmlValidator.setInstance( new XmlValidator( loader ) );
// save the context and pass its filename as an arg to the main
SourceSet[] sourceSets = new SourceSet[filesets.size()];
- for( int i = 0; i < filesets.size(); i++ )
- {
+ 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();
- for( int j = 0; j < files.length; j++ )
- {
+ for (int j = 0; j < files.length; j++) {
System.out.println( "Adding " + dir + " " +
files[j] );
}
sourceSets[i] = new SourceSet( dir, files );
}
- for( int i = 0; i < sourceSets.length; i++ )
- {
+ for (int i = 0; i < sourceSets.length; i++) {
XJavaDoc.getInstance().addSourceSet( sourceSets[i] );
}
executeSubTasks();
- }
- catch( Exception e )
- {
+ } catch (Exception e) {
e.printStackTrace();
throw new BuildException( e );
}
}
+
/**
* Gets the SubTasks attribute of the DocletTask object
*
* @return The SubTasks value
*/
- protected List getSubTasks()
- {
+ protected List getSubTasks() {
ArrayList true_subtasks = new ArrayList();
- for( int i = 0; i < templates.size(); i++ )
- {
+ for (int i = 0; i < templates.size(); i++) {
TemplateSubTask holder = ( TemplateSubTask ) templates.get( i
);
SubTask subtask = getSubTaskFromPlaceHolder( holder );
- if( subtask == null )
- {
+ if (subtask == null) {
System.out.println( Translator.getString(
"couldnt_instantiate_subtask", new String[]{holder.getSubTaskClassName()} ) );
continue;
}
@@ -416,6 +436,7 @@
return true_subtasks;
}
+
/**
* Gets the SubTaskFromPlaceHolder attribute of the DocletTask object
*
@@ -423,16 +444,13 @@
* @return The SubTaskFromPlaceHolder value
* @todo-javadoc Write javadocs for method parameter
*/
- protected SubTask getSubTaskFromPlaceHolder( TemplateSubTask holder )
- {
+ protected SubTask getSubTaskFromPlaceHolder(TemplateSubTask holder) {
//no subtask class specified
- if( holder.getSubTaskClassName() == null )
- {
+ if (holder.getSubTaskClassName() == null) {
return holder;
}
- try
- {
+ try {
Class subtask_class = Class.forName(
holder.getSubTaskClassName() );
TemplateSubTask subtask = ( TemplateSubTask )
subtask_class.newInstance();
@@ -440,31 +458,24 @@
subtask.copyAttributesFrom( holder );
return subtask;
- }
- catch( ClassNotFoundException e )
- {
+ } catch (ClassNotFoundException e) {
return null;
- }
- catch( InstantiationException e )
- {
+ } catch (InstantiationException e) {
return null;
- }
- catch( IllegalAccessException e )
- {
+ } catch (IllegalAccessException e) {
return null;
}
}
+
/**
* Returns the singleton context object and creates it if not already created
* and registers it as the single instance.
*
* @return the singleton context object
*/
- protected DocletContext getContext()
- {
- if( context != null )
- {
+ protected DocletContext getContext() {
+ if (context != null) {
return context;
}
@@ -487,6 +498,7 @@
return context;
}
+
/**
* Gets the ConfigParams attribute of the DocletTask object
*
@@ -494,20 +506,17 @@
* @return The ConfigParams value
* @todo-javadoc Write javadocs for method parameter
*/
- protected HashMap getConfigParams( List subtasks )
- {
+ protected HashMap getConfigParams(List subtasks) {
HashMap configs = new HashMap();
//config params of task
ConfigParamIntrospector.fillConfigParamsFor( this, configs );
//config params of substask
- for( int i = 0; i < subtasks.size(); i++ )
- {
+ for (int i = 0; i < subtasks.size(); i++) {
SubTask sub_task = ( SubTask ) subtasks.get( i );
- if( sub_task != null )
- {
+ if (sub_task != null) {
ConfigParamIntrospector.fillConfigParamsFor( sub_task,
configs );
//user defined params of SubTask
@@ -521,6 +530,7 @@
return configs;
}
+
/**
* Describe what the method does
*
@@ -528,26 +538,23 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- protected void validateOptions() throws BuildException
- {
- if( filesets.size() == 0 )
- {
+ protected void validateOptions() throws BuildException {
+ if (filesets.size() == 0) {
throw new BuildException( "At least one fileset must be
specified", location );
}
- if( destDir == null )
- {
+ if (destDir == null) {
throw new BuildException( Translator.getString(
"attribute_not_present_error", new String[]{"destDir"} ), location );
}
- if( classpath == null )
- {
+ if (classpath == null) {
classpath = org.apache.tools.ant.types.Path.systemClasspath;
}
validateSubTasks();
}
+
/**
* Describe what the method does
*
@@ -555,83 +562,67 @@
* @todo-javadoc Write javadocs for method
* @todo-javadoc Write javadocs for exception
*/
- protected void validateSubTasks() throws BuildException
- {
+ protected void validateSubTasks() throws BuildException {
DocletContext context = getContext();
SubTask[] subtasks = context.getSubTasks();
- for( int i = 0; i < subtasks.length; i++ )
- {
+ for (int i = 0; i < subtasks.length; i++) {
SubTask subtask = subtasks[i];
- if( subtask != null )
- {
- try
- {
+ if (subtask != null) {
+ try {
subtask.validateOptions();
- }
- catch( XDocletException ex )
- {
+ } catch (XDocletException ex) {
new BuildException( subtask.getSubTaskName() +
": " + ex.getMessage(), location );
}
}
}
}
+
/**
* Describe what the method does
*
* @todo-javadoc Write javadocs for method
*/
- private void executeSubTasks()
- {
+ 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++ )
- {
+ for (int i = 0; i < subtasks.length; i++) {
SubTask subtask = subtasks[i];
- if( subtask != null )
- {
- if( cat.isDebugEnabled() )
- {
+ if (subtask != null) {
+ if (cat.isDebugEnabled()) {
cat.debug( "SubTask " +
subtasks[i].getSubTaskName() + "Initialized." );
}
- try
- {
+ 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 )
- {
+ } catch (XDocletException e) {
System.out.println( Translator.getString(
"running_failed" ) );
System.out.println( "<<" + e.getMessage() +
">>" );
- if( e.getNestedException() != null )
- {
+ if (e.getNestedException() != null) {
e.getNestedException().printStackTrace();
}
- if( e.getNestedException() instanceof
TemplateException )
- {
+ if (e.getNestedException() instanceof
TemplateException) {
TemplateException template_ex = (
TemplateException ) e.getNestedException();
- if( cat.isDebugEnabled() )
- {
+ if (cat.isDebugEnabled()) {
cat.error( "Template Exception
= " + template_ex );
cat.error( "Nested Exception =
" + template_ex.getNestedException() );
}
}
- if( cat.isDebugEnabled() )
- {
+ if (cat.isDebugEnabled()) {
cat.error( "Exception trace:\n" +
e.getPrintStackTrace() );
}
@@ -643,6 +634,7 @@
}
}
+
/**
* Describe what the method does
*
@@ -654,11 +646,9 @@
* @todo-javadoc Write javadocs for method parameter
* @todo-javadoc Write javadocs for method parameter
*/
- private void fillWithUserDefinedConfigParams( HashMap configs, ArrayList
config_params, String prefix )
- {
+ private void fillWithUserDefinedConfigParams(HashMap configs, ArrayList
config_params, String prefix) {
//config params declared with <configParam name="nnn" value="val"/>
- for( int i = 0; i < config_params.size(); i++ )
- {
+ for (int i = 0; i < config_params.size(); i++) {
ConfigParameter config_param = ( ConfigParameter )
config_params.get( i );
configs.put( ( prefix + config_param.getName()
).toLowerCase(), config_param.getValue() );
_______________________________________________
Xdoclet-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/xdoclet-devel