You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by jv...@apache.org on 2001/09/18 15:59:59 UTC

cvs commit: jakarta-velocity/src/java/org/apache/velocity/texen/ant TexenTask.java

jvanzyl     01/09/18 06:59:59

  Modified:    src/java/org/apache/velocity/texen/ant TexenTask.java
  Log:
  - if a texen task is defined as follows:
  
    <torque-sql
      contextProperties="${build.properties}"
      controlTemplate="${SQLControlTemplate}"
      outputDirectory="${src.dir}/sql"
      templatePath="${templatePath}"
      outputFile="report.${project}.sql.generation"
      xmlFile="${conf.dir}/${project}-schema.xml"
      targetDatabase="${database}"
    />
  
    we are now protecting against the contextProperties attribute
    not being set. if this attribute was null it was throwing an NPE
    but the task reported success.
  
    we will now throw a BuildException if the resource represented by
    the contextProperties attribute cannot be found in the file system
    or on the classpath.
  
  Revision  Changes    Path
  1.31      +11 -7     jakarta-velocity/src/java/org/apache/velocity/texen/ant/TexenTask.java
  
  Index: TexenTask.java
  ===================================================================
  RCS file: /home/cvs/jakarta-velocity/src/java/org/apache/velocity/texen/ant/TexenTask.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- TexenTask.java	2001/08/31 20:18:24	1.30
  +++ TexenTask.java	2001/09/18 13:59:58	1.31
  @@ -58,27 +58,22 @@
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.Map;
  -
   import java.io.File;
   import java.io.FileWriter;
   import java.io.FileOutputStream;
   import java.io.FileInputStream;
   import java.io.InputStream;
   import java.io.IOException;
  -
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Task;
  -
   import org.apache.velocity.VelocityContext;
   import org.apache.velocity.app.Velocity;
   import org.apache.velocity.context.Context;
   import org.apache.velocity.texen.Generator;
   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;
   
   /**
  @@ -86,7 +81,7 @@
    *
    * @author <a href="mailto:jvanzyl@periapt.com">Jason van Zyl</a>
    * @author <a href="robertdonkin@mac.com">Robert Burrell Donkin</a>
  - * @version $Id: TexenTask.java,v 1.30 2001/08/31 20:18:24 jvanzyl Exp $
  + * @version $Id: TexenTask.java,v 1.31 2001/09/18 13:59:58 jvanzyl Exp $
    */
   public class TexenTask 
       extends Task
  @@ -277,7 +272,16 @@
               try
               {
                   InputStream inputStream = classLoader.getResourceAsStream(file);
  -                contextProperties.load(inputStream);
  +                
  +                if (inputStream == null)
  +                {
  +                    throw new BuildException("Context properties file " + file + " could " +
  +                        " not be found in the file system or on the classpath!");
  +                }
  +                else
  +                {
  +                    contextProperties.load(inputStream);
  +                }
               }
               catch (IOException ioe)
               {