Browse Source

try to support Tomcat 5.x

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276647 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
cc141e87cd
3 changed files with 58 additions and 10 deletions
  1. +5
    -0
      WHATSNEW
  2. +7
    -0
      docs/manual/OptionalTasks/jspc.html
  3. +46
    -10
      src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java

+ 5
- 0
WHATSNEW View File

@@ -259,6 +259,11 @@ Other changes:
* <junitreport> now also works with Xalan XSLTC and/or JDK 1.5. * <junitreport> now also works with Xalan XSLTC and/or JDK 1.5.
Bugzilla Report 27541. 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 Changes from Ant 1.6.0 to Ant 1.6.1
============================================= =============================================




+ 7
- 0
docs/manual/OptionalTasks/jspc.html View File

@@ -11,6 +11,13 @@
<h3>Description</h3> <h3>Description</h3>


<p> Ant task to run the JSP compiler and turn JSP pages into Java source. <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> <p>


It can be used to precompile JSP pages for fast initial invocation It can be used to precompile JSP pages for fast initial invocation


+ 46
- 10
src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java View File

@@ -18,6 +18,7 @@
package org.apache.tools.ant.taskdefs.optional.jsp.compilers; package org.apache.tools.ant.taskdefs.optional.jsp.compilers;


import java.io.File; import java.io.File;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Java; import org.apache.tools.ant.taskdefs.Java;
@@ -52,23 +53,19 @@ public class JasperC extends DefaultJspCompilerAdapter {
getJspc().log("Using jasper compiler", Project.MSG_VERBOSE); getJspc().log("Using jasper compiler", Project.MSG_VERBOSE);
CommandlineJava cmd = setupJasperCommand(); CommandlineJava cmd = setupJasperCommand();



try { try {
// Create an instance of the compiler, redirecting output to // Create an instance of the compiler, redirecting output to
// the project log // the project log
Java java = (Java) (getProject().createTask("java")); Java java = (Java) (getProject().createTask("java"));
Path p = getClasspath();
if (getJspc().getClasspath() != null) { 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 { } 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); Project.MSG_DEBUG);
java.setClasspath(classpath);
} }
java.setClasspath(p);
java.setDir(getProject().getBaseDir()); java.setDir(getProject().getBaseDir());
java.setClassname("org.apache.jasper.JspC"); java.setClassname("org.apache.jasper.JspC");
//this is really irritating; we need a way to set stuff //this is really irritating; we need a way to set stuff
@@ -106,7 +103,15 @@ public class JasperC extends DefaultJspCompilerAdapter {
JspC jspc = getJspc(); JspC jspc = getJspc();
addArg(cmd, "-d", jspc.getDestdir()); addArg(cmd, "-d", jspc.getDestdir());
addArg(cmd, "-p", jspc.getPackage()); 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, "-uriroot", jspc.getUriroot());
addArg(cmd, "-uribase", jspc.getUribase()); addArg(cmd, "-uribase", jspc.getUribase());
addArg(cmd, "-ieplugin", jspc.getIeplugin()); addArg(cmd, "-ieplugin", jspc.getIeplugin());
@@ -132,4 +137,35 @@ public class JasperC extends DefaultJspCompilerAdapter {
public JspMangler createMangler() { public JspMangler createMangler() {
return mangler; 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();
}
}
}
} }

Loading…
Cancel
Save