Browse Source

Make <taskdef> and <property> do their job in execute instead of

init. Call execute on tasks living outside of <target>s at parser time.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267951 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
4a96c6e0b7
3 changed files with 7 additions and 21 deletions
  1. +2
    -0
      src/main/org/apache/tools/ant/ProjectHelper.java
  2. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Property.java
  3. +3
    -19
      src/main/org/apache/tools/ant/taskdefs/Taskdef.java

+ 2
- 0
src/main/org/apache/tools/ant/ProjectHelper.java View File

@@ -360,6 +360,8 @@ public class ProjectHelper {
if (target != null) {
task.setOwningTarget(target);
target.addTask(task);
} else {
task.execute();
}
}



+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Property.java View File

@@ -107,7 +107,7 @@ public class Property extends Task {
return resource;
}

public void init() throws BuildException {
public void execute() throws BuildException {
try {
if ((name != null) && (value != null)) {
addProperty(name, value);
@@ -118,7 +118,7 @@ public class Property extends Task {
if (resource != null) loadResource(resource);

} catch (Exception e) {
throw new BuildException(e);
throw new BuildException(e, location);
}
}



+ 3
- 19
src/main/org/apache/tools/ant/taskdefs/Taskdef.java View File

@@ -65,15 +65,9 @@ public class Taskdef extends Task {
private String name;
private String value;

//
// REVISIT: Is this the right thing to do?
// I moved the body of execute() into init().
// - akv
//
public void init() throws BuildException {
try {
public void execute() throws BuildException {
if (name==null || value==null ) {
String msg = "name or class attributes of taskdef element "
String msg = "name or classname attributes of taskdef element "
+ "are undefined";
throw new BuildException(msg);
}
@@ -83,24 +77,14 @@ public class Taskdef extends Task {
} catch (ClassNotFoundException cnfe) {
String msg = "taskdef class " + value +
" cannot be found";
throw new BuildException(msg);
throw new BuildException(msg, location);
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void setName( String name) {
this.name = name;
}

public void XsetClass(String v) {
log("The class attribute is deprecated. " +
"Please use the classname attribute.",
Project.MSG_WARN);
value = v;
}

public String getClassname() {
return value;
}


Loading…
Cancel
Save