Author: wglass Date: Sun Feb 6 13:42:22 2005 New Revision: 151623 URL: http://svn.apache.org/viewcvs?view=rev&rev=151623 Log: Use System classloader for loading resources in Texen (reverting to PREV revision). This is apparently required due to ant oddities.
Using the ClassUtils.getResourceAsStream worked locally under ant 1.6 but failed on GUMP with ant of unknown version. Modified: jakarta/velocity/trunk/src/java/org/apache/velocity/texen/ant/TexenTask.java jakarta/velocity/trunk/src/java/org/apache/velocity/texen/util/PropertiesUtil.java Modified: jakarta/velocity/trunk/src/java/org/apache/velocity/texen/ant/TexenTask.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/trunk/src/java/org/apache/velocity/texen/ant/TexenTask.java?view=diff&r1=151622&r2=151623 ============================================================================== --- jakarta/velocity/trunk/src/java/org/apache/velocity/texen/ant/TexenTask.java (original) +++ jakarta/velocity/trunk/src/java/org/apache/velocity/texen/ant/TexenTask.java Sun Feb 6 13:42:22 2005 @@ -16,28 +16,26 @@ * limitations under the License. */ -import java.util.StringTokenizer; -import java.util.Date; -import java.util.Iterator; - import java.io.File; -import java.io.Writer; import java.io.FileInputStream; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.Writer; +import java.util.Date; +import java.util.Iterator; +import java.util.StringTokenizer; +import org.apache.commons.collections.ExtendedProperties; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.VelocityEngine; import org.apache.velocity.context.Context; -import org.apache.velocity.texen.Generator; -import org.apache.velocity.util.ClassUtils; -import org.apache.velocity.util.StringUtils; import org.apache.velocity.exception.MethodInvocationException; import org.apache.velocity.exception.ParseErrorException; import org.apache.velocity.exception.ResourceNotFoundException; -import org.apache.commons.collections.ExtendedProperties; +import org.apache.velocity.texen.Generator; +import org.apache.velocity.util.StringUtils; /** * An ant task for generating output by using Velocity @@ -284,11 +282,12 @@ } catch (Exception e) { + ClassLoader classLoader = this.getClass().getClassLoader(); + try { - - InputStream inputStream = ClassUtils.getResourceAsStream(getClass(),sources[i]); - + InputStream inputStream = classLoader.getResourceAsStream(sources[i]); + if (inputStream == null) { throw new BuildException("Context properties file " + sources[i] + @@ -401,14 +400,14 @@ // Setup the Velocity Runtime. if (templatePath != null) { - log("Using templatePath: " + templatePath, project.MSG_VERBOSE); + log("Using templatePath: " + templatePath, project.MSG_VERBOSE); ve.setProperty( ve.FILE_RESOURCE_LOADER_PATH, templatePath); } if (useClasspath) { - log("Using classpath"); + log("Using classpath"); ve.addProperty( VelocityEngine.RESOURCE_LOADER, "classpath"); Modified: jakarta/velocity/trunk/src/java/org/apache/velocity/texen/util/PropertiesUtil.java URL: http://svn.apache.org/viewcvs/jakarta/velocity/trunk/src/java/org/apache/velocity/texen/util/PropertiesUtil.java?view=diff&r1=151622&r2=151623 ============================================================================== --- jakarta/velocity/trunk/src/java/org/apache/velocity/texen/util/PropertiesUtil.java (original) +++ jakarta/velocity/trunk/src/java/org/apache/velocity/texen/util/PropertiesUtil.java Sun Feb 6 13:42:22 2005 @@ -17,12 +17,12 @@ */ import java.io.FileInputStream; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.util.Properties; import java.util.StringTokenizer; + import org.apache.velocity.texen.Generator; -import org.apache.velocity.util.ClassUtils; /** * A property utility class for the texen text/code generator @@ -139,6 +139,7 @@ protected Properties loadFromClassPath(String propertiesFile) { Properties properties = new Properties(); + ClassLoader classLoader = this.getClass().getClassLoader(); try { @@ -155,7 +156,7 @@ "$generator.templatePath/".length()); } - InputStream inputStream = ClassUtils.getResourceAsStream( getClass(), propertiesFile ); + InputStream inputStream = classLoader.getResourceAsStream(propertiesFile); properties.load(inputStream); } catch (IOException ioe) --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]