You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ak...@locus.apache.org on 2000/03/02 21:40:05 UTC

cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Taskdef.java

akv         00/03/02 12:40:05

  Modified:    src/main/org/apache/tools/ant Project.java
               src/main/org/apache/tools/ant/taskdefs Taskdef.java
  Log:
  (Possibly temporary) Fix for getting Taskdef in build files to actually work.
  Fixing this because watchdog is broken.
  
  Revision  Changes    Path
  1.13      +6 -5      jakarta-ant/src/main/org/apache/tools/ant/Project.java
  
  Index: Project.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Project.java	2000/02/24 01:34:44	1.12
  +++ Project.java	2000/03/02 20:40:04	1.13
  @@ -353,13 +353,14 @@
       }
   
       public Task createTask(String taskType) throws BuildException {
  -        Class c = (Class)taskClassDefinitions.get(taskType);
  +        Class c = (Class) taskClassDefinitions.get(taskType);
   
  -        // XXX
  -        // check for nulls, other sanity
  -
  +	if (c == null)
  +	    throw new BuildException("Could not create task of type: "+taskType+
  +				     " because I can't find it in the list of task"+
  +				     " class definitions");
           try {
  -            Object o=c.newInstance();
  +            Object o = c.newInstance();
               Task task = null;
               if( o instanceof Task ) {
                  task=(Task)o;
  
  
  
  1.4       +9 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Taskdef.java
  
  Index: Taskdef.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Taskdef.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Taskdef.java	2000/02/16 14:31:45	1.3
  +++ Taskdef.java	2000/03/02 20:40:04	1.4
  @@ -64,8 +64,13 @@
   public class Taskdef extends Task {
       private String name;
       private String value;
  -    
  -    public void execute() throws BuildException {
  +
  +    //
  +    // REVISIT: Is this the right thing to do?
  +    //          I moved the body of execute() into init().
  +    //                               - akv
  +    //
  +    public void init() throws BuildException {
   	try {
   	    if (name==null || value==null ) {
   		String msg = "name or class attributes of taskdef element "
  @@ -74,7 +79,7 @@
   	    }
   	    try {
   		Class taskClass = Class.forName(value);
  -		project.addTaskDefinition(name, taskClass);
  +			project.addTaskDefinition(name, taskClass);
   	    } catch (ClassNotFoundException cnfe) {
   		String msg = "taskdef class " + value +
   		    " cannot be found";
  @@ -84,7 +89,7 @@
   	    ex.printStackTrace();
   	}
       }
  -
  +    
       public void setName( String name) {
   	this.name = name;
       }