tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject cvs commit: jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper JspC.java
Date Fri, 22 Jul 2005 14:46:24 GMT
yoavs       2005/07/22 07:46:24

  Modified:    webapps/docs changelog.xml
               jasper2/src/share/org/apache/jasper JspC.java
  Log:
  Bugzilla 35571: http://issues.apache.org/bugzilla/show_bug.cgi?id=35571
  
  Note: using a method (FileUtils.getFileUtils) which was deprecated in
  Ant 1.6.3, but will be available for a while.  If we ever require
  Ant 1.6.3 or later for building, we can update the method call.
  
  Revision  Changes    Path
  1.334     +4 -0      jakarta-tomcat-catalina/webapps/docs/changelog.xml
  
  Index: changelog.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-catalina/webapps/docs/changelog.xml,v
  retrieving revision 1.333
  retrieving revision 1.334
  diff -u -r1.333 -r1.334
  --- changelog.xml	22 Jul 2005 13:47:53 -0000	1.333
  +++ changelog.xml	22 Jul 2005 14:46:24 -0000	1.334
  @@ -269,6 +269,10 @@
         <fix>
           <bug>35410</bug>: Fixed NPE in JspWriterImpl. (yoavs)
         </fix>
  +      <add>
  +        <bug>35571</bug>: JspC resolved uriRoot relative to Ant project basedir,
if any, as suggested
  +          by Jason Pettiss. (yoavs)
  +      </add>
       </changelog>
     </subsection>
     
  
  
  
  1.98      +49 -6     jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java
  
  Index: JspC.java
  ===================================================================
  RCS file: /home/cvs/jakarta-tomcat-jasper/jasper2/src/share/org/apache/jasper/JspC.java,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- JspC.java	21 Jul 2005 21:23:48 -0000	1.97
  +++ JspC.java	22 Jul 2005 14:46:24 -0000	1.98
  @@ -46,7 +46,10 @@
   import org.apache.jasper.compiler.TagPluginManager;
   import org.apache.jasper.compiler.TldLocationsCache;
   import org.apache.jasper.servlet.JspCServletContext;
  +
   import org.apache.tools.ant.AntClassLoader;
  +import org.apache.tools.ant.Project;
  +import org.apache.tools.ant.util.FileUtils;
   
   /**
    * Shell for the jspc compiler.  Handles all options associated with the
  @@ -146,6 +149,7 @@
       private String targetClassName;
       private String uriBase;
       private String uriRoot;
  +    private Project project;
       private int dieLevel;
       private boolean helpNeeded = false;
       private boolean compile = false;
  @@ -602,18 +606,37 @@
       }
   
       /**
  +     * Sets the project.
  +     *
  +     * @param theProject The project
  +     */
  +    public void setProject(final Project theProject) {
  +        project = theProject;
  +    }
  +
  +    /**
  +     * Returns the project: may be null if not running
  +     * inside an Ant project.
  +     *
  +     * @return The project
  +     */
  +    public Project getProject() {
  +        return project;
  +    }
  +
  +    /**
        * Base dir for the webapp. Used to generate class names and resolve
        * includes
        */
       public void setUriroot( String s ) {
           if( s==null ) {
  -            uriRoot=s;
  +            uriRoot = s;
               return;
           }
           try {
  -            uriRoot=new File( s ).getCanonicalPath();
  +            uriRoot = resolveFile(s).getCanonicalPath();
           } catch( Exception ex ) {
  -            uriRoot=s;
  +            uriRoot = s;
           }
       }
   
  @@ -654,7 +677,7 @@
   
       public void setOutputDir( String s ) {
           if( s!= null ) {
  -            scratchDir = new File(s).getAbsoluteFile();
  +            scratchDir = resolveFile(s).getAbsoluteFile();
           } else {
               scratchDir=null;
           }
  @@ -677,7 +700,7 @@
        * File where we generate a web.xml fragment with the class definitions.
        */
       public void setWebXmlFragment( String s ) {
  -        webxmlFile=s;
  +        webxmlFile=resolveFile(s).getAbsolutePath();
           webxmlLevel=INC_WEBXML;
       }
   
  @@ -685,7 +708,7 @@
        * File where we generate a complete web.xml with the class definitions.
        */
       public void setWebXml( String s ) {
  -        webxmlFile=s;
  +        webxmlFile=resolveFile(s).getAbsolutePath();
           webxmlLevel=ALL_WEBXML;
       }
   
  @@ -1280,4 +1303,24 @@
               // pass straight through
           }
       }
  +
  +    /**
  +     * Resolves the relative or absolute pathname correctly
  +     * in both Ant and command-line situations.  If Ant launched
  +     * us, we should use the basedir of the current project
  +     * to resolve relative paths.
  +     *
  +     * See Bugzilla 35571.
  +     *
  +     * @param s The file
  +     * @return The file resolved
  +     */
  +     protected File resolveFile(final String s) {
  +         if(getProject() == null) {
  +             // Note FileUtils.getFileUtils replaces FileUtils.newFileUtils in Ant 1.6.3
  +             return FileUtils.newFileUtils().resolveFile(null, s);
  +         } else {
  +             return FileUtils.newFileUtils().resolveFile(getProject().getBaseDir(), s);
  +         }
  +     }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Mime
View raw message