Browse Source

(Possibly temporary) Fix for getting Taskdef in build files to actually work.

Fixing this because watchdog is broken.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267625 13f79535-47bb-0310-9956-ffa450edef68
master
akv 25 years ago
parent
commit
efbabaf849
2 changed files with 15 additions and 9 deletions
  1. +6
    -5
      src/main/org/apache/tools/ant/Project.java
  2. +9
    -4
      src/main/org/apache/tools/ant/taskdefs/Taskdef.java

+ 6
- 5
src/main/org/apache/tools/ant/Project.java View File

@@ -353,13 +353,14 @@ public class Project {
}

public Task createTask(String taskType) throws BuildException {
Class c = (Class)taskClassDefinitions.get(taskType);

// XXX
// check for nulls, other sanity
Class c = (Class) taskClassDefinitions.get(taskType);

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;


+ 9
- 4
src/main/org/apache/tools/ant/taskdefs/Taskdef.java View File

@@ -64,8 +64,13 @@ import org.apache.tools.ant.*;
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 @@ public class Taskdef extends Task {
}
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 @@ public class Taskdef extends Task {
ex.printStackTrace();
}
}
public void setName( String name) {
this.name = name;
}


Loading…
Cancel
Save