Author: hibou
Date: Sun Feb 28 10:54:06 2010
New Revision: 917165
URL: http://svn.apache.org/viewvc?rev=917165&view=rev
Log:
handle groovy build file with dashed names
Modified:
ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontProjectHelper.java
Modified:
ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontProjectHelper.java
URL:
http://svn.apache.org/viewvc/ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontProjectHelper.java?rev=917165&r1=917164&r2=917165&view=diff
==============================================================================
---
ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontProjectHelper.java
(original)
+++
ant/sandbox/groovyfront/src/main/java/org/apache/ant/groovyfront/GroovyFrontProjectHelper.java
Sun Feb 28 10:54:06 2010
@@ -99,6 +99,9 @@
buildFileName = url.toString();
in = url.openStream();
// } else if (source instanceof InputSource ) {
+ } else if (source instanceof Resource) {
+ buildFileName = ((Resource) source).getName();
+ in = ((Resource) source).getInputStream();
} else {
throw new BuildException("Source " +
source.getClass().getName() + " not supported by this plugin");
}
@@ -129,7 +132,7 @@
GroovyShell groovyShell = new GroovyShell(getClass().getClassLoader(),
binding);
final Script script;
try {
- script = groovyShell.parse(new InputStreamReader(in),
buildFileName);
+ script = groovyShell.parse(new InputStreamReader(in),
asGroovyClass(buildFileName));
} catch (CompilationFailedException e) {
throw new BuildException("Error reading groovy file " +
buildFileName + ": " + e.getMessage(), e);
}
@@ -143,4 +146,7 @@
}.run();
}
+ private String asGroovyClass(String filename) {
+ return filename.replaceAll("-", "_");
+ }
}