jon 00/11/25 12:44:08
Modified: src/java/org/apache/velocity/anakia AnakiaTask.java
Log:
updated to take advantage of latest relativePath changes
Revision Changes Path
1.8 +10 -4
jakarta-velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java
Index: AnakiaTask.java
===================================================================
RCS file:
/home/cvs/jakarta-velocity/src/java/org/apache/velocity/anakia/AnakiaTask.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- AnakiaTask.java 2000/11/23 13:54:58 1.7
+++ AnakiaTask.java 2000/11/25 20:44:08 1.8
@@ -72,6 +72,7 @@
// Velocity Stuff
import org.apache.velocity.*;
import org.apache.velocity.runtime.Runtime;
+import org.apache.velocity.util.StringUtils;
/**
The purpose of this Ant Task is to allow you to use
@@ -87,7 +88,7 @@
it for this project.
@author <a href="[EMAIL PROTECTED]">Jon S. Stevens</a>
- @version $Id: AnakiaTask.java,v 1.7 2000/11/23 13:54:58 werken Exp $
+ @version $Id: AnakiaTask.java,v 1.8 2000/11/25 20:44:08 jon Exp $
*/
public class AnakiaTask extends MatchingTask
{
@@ -303,7 +304,7 @@
context.put ("xmlout", new XMLOutputter());
context.put ("relativePath", getRelativePath(xmlFile));
context.put ("xpath", new XPathTool() );
-
+
// only put this into the context if it exists.
if (projectDocument != null)
context.put ("project", projectDocument.getRootElement());
@@ -329,7 +330,7 @@
// log("Failed to process " + inFile, Project.MSG_INFO);
if (outFile != null ) outFile.delete();
}
- catch (Exception e)
+ catch (Throwable e)
{
// log("Failed to process " + inFile, Project.MSG_INFO);
if (outFile != null ) outFile.delete();
@@ -357,6 +358,8 @@
*/
private String getRelativePath(String file)
{
+ if (file == null || file.length()==0)
+ return "";
StringTokenizer st = new StringTokenizer(file, "/\\");
// needs to be -1 cause ST returns 1 even if there are no matches. huh?
int slashCount = st.countTokens() - 1;
@@ -365,7 +368,10 @@
{
sb.append ("../");
}
- return sb.toString();
+ if (sb.toString().length() > 0)
+ return StringUtils.chop(sb.toString(), 1);
+ else
+ return ".";
}
/**
create directories as needed