ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet AntSubTask.java AntTagsHandler.java
Date Wed, 27 Feb 2002 19:39:41 GMT
ehatcher    02/02/27 11:39:41

  Modified:    proposal/xdocs/src/org/apache/tools/ant/xdoclet
                        AntSubTask.java AntTagsHandler.java
  Log:
  Fixed some issues with defaults.properties generation. Fixed issue with build having to
be run twice because of directory being removed from the path (*arg*!).
  
  Revision  Changes    Path
  1.2       +28 -7     jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java
  
  Index: AntSubTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntSubTask.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntSubTask.java	27 Feb 2002 05:25:36 -0000	1.1
  +++ AntSubTask.java	27 Feb 2002 19:39:41 -0000	1.2
  @@ -83,15 +83,31 @@
        *       - and only throw BuildException if at all
        */
       protected boolean matchesGenerationRules(ClassDoc clazz) throws XDocletException {
  -        MethodDoc[] methods = clazz.methods();
   
           if (clazz.isAbstract()) {
               return false;
           }
   
  +        return isAntTask(clazz);;
  +    }
  +
  +    /**
  +     * @todo pull out to utility method
  +     * @todo add more logic (like execute method signature)
  +     */
  +    public static final boolean isAntTask(ClassDoc clazz) {
  +        if (clazz.isAbstract()) {
  +            return false;
  +        }
  +
  +        // no inner classes (for now - but is this possible? desired?)
  +        if (clazz.containingClass() != null) {
  +            return false;
  +        }
  +
  +        MethodDoc[] methods = clazz.methods();
           for (int i = 0; i < methods.length; i++) {
               if ("execute".equals(methods[i].name())) {
  -                System.out.println("Task: " + clazz.name());
                   return true;
               }
           }
  @@ -104,12 +120,17 @@
        * default class name.
        */
       protected String getGeneratedFileName(ClassDoc clazz) throws XDocletException {
  -        PackageDoc pak = clazz.containingPackage();
  -        String packageName = PackageTagsHandler.packageNameAsPathFor(pak);
  -        String taskName = AntTagsHandler.getTaskName(clazz);
  -        String filename = MessageFormat.format(getDestinationFile(), new Object[]{taskName});
  +        String filename = getDestinationFile();
  +        String dir = getDestDir().getAbsolutePath();
  +
  +        if (filename.indexOf("{0}") != -1) {
  +            PackageDoc pak = clazz.containingPackage();
  +            dir = PackageTagsHandler.packageNameAsPathFor(pak);
  +            String taskName = AntTagsHandler.getTaskName(clazz);
  +            filename = MessageFormat.format(getDestinationFile(), new Object[]{taskName});
  +        }
   
  -        return new File(packageName, filename).toString();
  +        return new File(dir, filename).toString();
       }
   
   }
  
  
  
  1.2       +27 -7     jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java
  
  Index: AntTagsHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/proposal/xdocs/src/org/apache/tools/ant/xdoclet/AntTagsHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AntTagsHandler.java	27 Feb 2002 05:25:36 -0000	1.1
  +++ AntTagsHandler.java	27 Feb 2002 19:39:41 -0000	1.2
  @@ -57,6 +57,7 @@
   import com.sun.javadoc.MethodDoc;
   import xdoclet.XDocletException;
   import xdoclet.XDocletTagSupport;
  +import xdoclet.tags.AbstractProgramElementTagsHandler;
   
   import java.util.ArrayList;
   import java.util.Arrays;
  @@ -81,6 +82,24 @@
   public class AntTagsHandler extends XDocletTagSupport {
   
       /**
  +     * @todo add check for execute method
  +     */
  +    public void forAllTasks(String template, Properties attributes) throws XDocletException
{
  +        ClassDoc[] classes = AbstractProgramElementTagsHandler.getAllClasses();
  +        ClassDoc cur_class = null;
  +
  +        for (int i = 0; i < classes.length; i++) {
  +            cur_class = classes[i];
  +            setCurrentClass(cur_class);
  +
  +            if (AntSubTask.isAntTask(cur_class)) {
  +                generate(template);
  +            }
  +        }
  +    }
  +
  +
  +    /**
        * Iterates over all Ant attributes.
        *
        *@param  template              XDoclet template
  @@ -120,21 +139,22 @@
           }
       }
   
  +
       /**
        * Provides the element name for the current method
        */
       public String elementName() throws XDocletException {
           String methodName = getCurrentMethod().name();
  -        System.out.println(">>>> " + methodName);
           String elementName = "<not a valid element>";
           if (methodName.startsWith("addConfigured")) {
  -            elementName = methodName.substring(13,methodName.length());
  -        } else if (methodName.startsWith("add")) {
  -            elementName = methodName.substring(3,methodName.length());
  -        } else if (methodName.startsWith("create")) {
  -            elementName = methodName.substring(6,methodName.length());
  +            elementName = methodName.substring(13, methodName.length());
  +        }
  +        else if (methodName.startsWith("add")) {
  +            elementName = methodName.substring(3, methodName.length());
  +        }
  +        else if (methodName.startsWith("create")) {
  +            elementName = methodName.substring(6, methodName.length());
           }
  -        System.out.println("        = " + elementName);
           return elementName.toLowerCase();
       }
   
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message