Browse Source

Supply location when complaining about empty target names.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273311 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
ea5d48a63b
2 changed files with 16 additions and 3 deletions
  1. +13
    -0
      src/main/org/apache/tools/ant/Location.java
  2. +3
    -3
      src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java

+ 13
- 0
src/main/org/apache/tools/ant/Location.java View File

@@ -55,6 +55,7 @@
package org.apache.tools.ant;

import java.io.Serializable;
import org.xml.sax.Locator;

/**
* Stores the location of a piece of text within a file (file name,
@@ -92,6 +93,18 @@ public class Location implements Serializable {
this(fileName, 0, 0);
}

/**
* Creates a location from the SAX locator using the system ID as
* the filename.
*
* @param locator Must not be <code>null</code>.
*
* @since Ant 1.6
*/
public Location(Locator loc) {
this(loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber());
}

/**
* Creates a location consisting of a file name, line number and
* column number.


+ 3
- 3
src/main/org/apache/tools/ant/helper/ProjectHelperImpl.java View File

@@ -578,7 +578,8 @@ public class ProjectHelperImpl extends ProjectHelper {
name = value;
if (name.equals("")) {
throw new BuildException("name attribute must not"
+ " be empty");
+ " be empty",
new Location(helperImpl.locator));
}
} else if (key.equals("depends")) {
depends = value;
@@ -783,8 +784,7 @@ public class ProjectHelperImpl extends ProjectHelper {
task.setTaskName(tag);
}

task.setLocation(new Location(helperImpl.locator.getSystemId(), helperImpl.locator.getLineNumber(),
helperImpl.locator.getColumnNumber()));
task.setLocation(new Location(helperImpl.locator));
helperImpl.configureId(task, attrs);

task.setOwningTarget(target);


Loading…
Cancel
Save