bodewig     2004/06/28 01:49:46

  Modified:    .        WHATSNEW
               docs/manual/OptionalTasks jspc.html
               src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers
                        JasperC.java
  Log:
  try to support Tomcat 5.x
  
  Revision  Changes    Path
  1.634     +5 -0      ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/ant/WHATSNEW,v
  retrieving revision 1.633
  retrieving revision 1.634
  diff -u -r1.633 -r1.634
  --- WHATSNEW  25 Jun 2004 13:50:33 -0000      1.633
  +++ WHATSNEW  28 Jun 2004 08:49:46 -0000      1.634
  @@ -259,6 +259,11 @@
   * <junitreport> now also works with Xalan XSLTC and/or JDK 1.5.
     Bugzilla Report 27541.
   
  +* <jspc> doesn't work properly with Tomcat 5.x.  We've implemented a
  +  work-around but don't intend to support future changes in Tomcat
  +  5.x.  Please use the jspc task that ships with Tomcat instead of
  +  Ant's.
  +
   Changes from Ant 1.6.0 to Ant 1.6.1
   =============================================
   
  
  
  
  1.18      +7 -0      ant/docs/manual/OptionalTasks/jspc.html
  
  Index: jspc.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/OptionalTasks/jspc.html,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- jspc.html 9 Feb 2004 21:50:08 -0000       1.17
  +++ jspc.html 28 Jun 2004 08:49:46 -0000      1.18
  @@ -11,6 +11,13 @@
   <h3>Description</h3>
   
   <p> Ant task to run the JSP compiler and turn JSP pages into Java source.
  +
  +<p><b>Deprecated</b> if you use this task with Tomcat's Jasper JSP
  +compiler, you should seriously consider using the task shipping with
  +Tomcat instead.  This task is only tested against Tomcat 4.x. There
  +are known problems with Tomcat 5.x that won't get fixed in Ant, please
  +use Tomcat's jspc task instead.</p>
  +
   <p>
   
   It can be used to precompile JSP pages for fast initial invocation
  
  
  
  1.23      +46 -10    
ant/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
  
  Index: JasperC.java
  ===================================================================
  RCS file: 
/home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JasperC.java      9 Mar 2004 16:48:30 -0000       1.22
  +++ JasperC.java      28 Jun 2004 08:49:46 -0000      1.23
  @@ -18,6 +18,7 @@
   package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
   
   import java.io.File;
  +import org.apache.tools.ant.AntClassLoader;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.taskdefs.Java;
  @@ -52,23 +53,19 @@
           getJspc().log("Using jasper compiler", Project.MSG_VERBOSE);
           CommandlineJava cmd = setupJasperCommand();
   
  -
           try {
               // Create an instance of the compiler, redirecting output to
               // the project log
               Java java = (Java) (getProject().createTask("java"));
  +            Path p = getClasspath();
               if (getJspc().getClasspath() != null) {
  -                getProject().log("using user supplied classpath: "
  -                    + getJspc().getClasspath(), Project.MSG_DEBUG);
  -                java.setClasspath(getJspc().getClasspath()
  -                                  .concatSystemClasspath("ignore"));
  +                getProject().log("using user supplied classpath: " + p, 
  +                                 Project.MSG_DEBUG);
               } else {
  -                Path classpath = new Path(getProject());
  -                classpath = classpath.concatSystemClasspath("only");
  -                getProject().log("using system classpath: " + classpath,
  +                getProject().log("using system classpath: " + p,
                                    Project.MSG_DEBUG);
  -                java.setClasspath(classpath);
               }
  +            java.setClasspath(p);
               java.setDir(getProject().getBaseDir());
               java.setClassname("org.apache.jasper.JspC");
               //this is really irritating; we need a way to set stuff
  @@ -106,7 +103,15 @@
           JspC jspc = getJspc();
           addArg(cmd, "-d", jspc.getDestdir());
           addArg(cmd, "-p", jspc.getPackage());
  -        addArg(cmd, "-v" + jspc.getVerbose());
  +
  +        if (!isTomcat5x()) {
  +            addArg(cmd, "-v" + jspc.getVerbose());
  +        } else {
  +            getProject().log("this task doesn't support Tomcat 5.x properly, 
"
  +                             + "please use the Tomcat provided jspc task "
  +                             + "instead");
  +        }
  +        
           addArg(cmd, "-uriroot", jspc.getUriroot());
           addArg(cmd, "-uribase", jspc.getUribase());
           addArg(cmd, "-ieplugin", jspc.getIeplugin());
  @@ -131,5 +136,36 @@
   
       public JspMangler createMangler() {
           return mangler;
  +    }
  +
  +    /**
  +     * @since Ant 1.6.2
  +     */
  +    private Path getClasspath() {
  +        Path p = getJspc().getClasspath();
  +        if (p == null) {
  +            p = new Path(getProject());
  +            return p.concatSystemClasspath("only");
  +        } else {
  +            return p.concatSystemClasspath("ignore");
  +        }
  +    }
  +
  +    /**
  +     * @since Ant 1.6.2
  +     */
  +    private boolean isTomcat5x() {
  +        AntClassLoader l = null;
  +        try {
  +            l = getProject().createClassLoader(getClasspath());
  +            l.loadClass("org.apache.jasper.tagplugins.jstl.If");
  +            return true;
  +        } catch (ClassNotFoundException e) {
  +            return false;
  +        } finally {
  +            if (l != null) {
  +                l.cleanup();
  +            }
  +        }
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to