aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp
diff options
context:
space:
mode:
Diffstat (limited to 'framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp')
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/Jasper41Mangler.java93
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java709
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspMangler.java47
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java155
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java334
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java153
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java182
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java64
-rw-r--r--framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java122
9 files changed, 1859 insertions, 0 deletions
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/Jasper41Mangler.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/Jasper41Mangler.java
new file mode 100644
index 00000000..609938c9
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/Jasper41Mangler.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs.optional.jsp;
+
+import java.io.File;
+
+/**
+ * this class implements the name mangling rules of the jasper in tomcat4.1.x
+ * which is likely to remain for some time
+ * @see "org.apache.jasper.JspCompilationContext"
+ */
+public class Jasper41Mangler implements JspMangler {
+
+
+ /**
+ * map from a jsp file to a java filename; does not do packages
+ *
+ * @param jspFile file
+ * @return java filename
+ */
+ public String mapJspToJavaName(File jspFile) {
+ String jspUri = jspFile.getAbsolutePath();
+ int start = jspUri.lastIndexOf(File.separatorChar) + 1;
+ int end = jspUri.length();
+ StringBuffer modifiedClassName;
+ modifiedClassName = new StringBuffer(jspUri.length() - start);
+ if (!Character.isJavaIdentifierStart(jspUri.charAt(start))
+ || jspUri.charAt(start) == '_') {
+ // If the first char is not a start of Java identifier or is _
+ // prepend a '_'.
+ modifiedClassName.append('_');
+ }
+ for (int i = start; i < end; i++) {
+ char ch = jspUri.charAt(i);
+ if (Character.isJavaIdentifierPart(ch)) {
+ modifiedClassName.append(ch);
+ } else if (ch == '.') {
+ modifiedClassName.append('_');
+ } else {
+ modifiedClassName.append(mangleChar(ch));
+ }
+ }
+ return modifiedClassName.toString();
+ }
+
+ /**
+ * Mangle the specified character to create a legal Java class name.
+ */
+ private static String mangleChar(char ch) {
+ // CheckStyle:MagicNumber OFF
+ String s = Integer.toHexString(ch);
+ int nzeros = 5 - s.length();
+ char[] result = new char[6];
+ result[0] = '_';
+ for (int i = 1; i <= nzeros; i++) {
+ result[i] = '0';
+ }
+ for (int i = nzeros + 1, j = 0; i < 6; i++, j++) {
+ result[i] = s.charAt(j);
+ }
+ return new String(result);
+ // CheckStyle:MagicNumber ON
+ }
+
+
+ /**
+ * taking in the substring representing the path relative to the source dir
+ * return a new string representing the destination path
+ * @param path not used.
+ * @return null as this is not implemented.
+ * @todo
+ */
+ public String mapPath(String path) {
+ return null;
+ }
+
+}
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
new file mode 100644
index 00000000..4274bf0d
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
@@ -0,0 +1,709 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs.optional.jsp;
+
+import java.io.File;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapter;
+import org.apache.tools.ant.taskdefs.optional.jsp.compilers.JspCompilerAdapterFactory;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
+
+/**
+ * Runs a JSP compiler.
+ *
+ * <p> This task takes the given jsp files and compiles them into java
+ * files. It is then up to the user to compile the java files into classes.
+ *
+ * <p> The task requires the srcdir and destdir attributes to be
+ * set. This Task is a MatchingTask, so the files to be compiled can be
+ * specified using includes/excludes attributes or nested include/exclude
+ * elements. Optional attributes are verbose (set the verbosity level passed
+ * to jasper), package (name of the destination package for generated java
+ * classes and classpath (the classpath to use when running the jsp
+ * compiler).
+ * <p> This task supports the nested elements classpath (A Path) and
+ * classpathref (A Reference) which can be used in preference to the
+ * attribute classpath, if the jsp compiler is not already in the ant
+ * classpath.
+ *
+ * <p><h4>Usage</h4>
+ * <pre>
+ * &lt;jspc srcdir="${basedir}/src/war"
+ * destdir="${basedir}/gensrc"
+ * package="com.i3sp.jsp"
+ * verbose="9"&gt;
+ * &lt;include name="**\/*.jsp" /&gt;
+ * &lt;/jspc&gt;
+ * </pre>
+ *
+ * <p> Large Amount of cutting and pasting from the Javac task...
+ * @since 1.5
+ */
+public class JspC extends MatchingTask {
+ private Path classpath;
+ private Path compilerClasspath;
+ private Path src;
+ private File destDir;
+ private String packageName;
+ /** name of the compiler to use */
+ private String compilerName = "jasper";
+
+ /**
+ * -ieplugin &lt;clsid&gt; Java Plugin classid for Internet Explorer
+ */
+ private String iepluginid;
+ private boolean mapped;
+ private int verbose = 0;
+ // CheckStyle:VisibilityModifier OFF - bc
+ protected Vector compileList = new Vector();
+ Vector javaFiles = new Vector();
+
+ /**
+ * flag to control action on execution trouble
+ */
+ protected boolean failOnError = true;
+
+ /**
+ * -uriroot &lt;dir&gt; The root directory that uri files should be resolved
+ * against,
+ */
+ private File uriroot;
+
+ /**
+ * -webinc &lt;file&gt; Creates partial servlet mappings for the -webapp option
+ */
+ private File webinc;
+
+ /**
+ * -webxml &lt;file&gt; Creates a complete web.xml when using the -webapp option.
+ */
+
+ private File webxml;
+
+ /**
+ * web apps
+ */
+ protected WebAppParameter webApp;
+
+
+
+ private static final String FAIL_MSG
+ = "Compile failed, messages should have been provided.";
+
+ // CheckStyle:VisibilityModifier ON
+
+ /**
+ * Set the path for source JSP files.
+ * @param srcDir the source path.
+ */
+ public void setSrcDir(Path srcDir) {
+ if (src == null) {
+ src = srcDir;
+ } else {
+ src.append(srcDir);
+ }
+ }
+
+ /**
+ * Get the source dir.
+ * @return the source path.
+ */
+ public Path getSrcDir() {
+ return src;
+ }
+
+ /**
+ * Set the destination directory into which the JSP source
+ * files should be compiled.
+ * @param destDir the destination directory.
+ */
+ public void setDestdir(File destDir) {
+ this.destDir = destDir;
+ }
+
+ /**
+ * Get the destination directory.
+ * @return the directory.
+ */
+ public File getDestdir() {
+ return destDir;
+ }
+
+ /**
+ * Set the name of the package the compiled jsp files should be in.
+ * @param pkg the name of the package.
+ */
+ public void setPackage(String pkg) {
+ this.packageName = pkg;
+ }
+
+ /**
+ * Get the name of the package.
+ * @return the package.
+ */
+ public String getPackage() {
+ return packageName;
+ }
+
+ /**
+ * Set the verbose level of the compiler
+ * @param i the verbose level to use.
+ */
+ public void setVerbose(int i) {
+ verbose = i;
+ }
+
+ /**
+ * Get the verbose level.
+ * @return the level.
+ */
+ public int getVerbose() {
+ return verbose;
+ }
+
+ /**
+ * Whether or not the build should halt if compilation fails.
+ * Defaults to <code>true</code>.
+ * @param fail a <code>boolean</code> value.
+ */
+ public void setFailonerror(boolean fail) {
+ failOnError = fail;
+ }
+ /**
+ * Gets the failonerror flag.
+ * @return the flag.
+ */
+ public boolean getFailonerror() {
+ return failOnError;
+ }
+
+ /**
+ * Get the IE CLASSID value.
+ * @return the value.
+ */
+ public String getIeplugin() {
+ return iepluginid;
+ }
+ /**
+ * Java Plugin CLASSID for Internet Explorer
+ * @param iepluginid the id to use.
+ */
+ public void setIeplugin(String iepluginid) {
+ this.iepluginid = iepluginid;
+ }
+
+ /**
+ * If true, generate separate write() calls for each HTML line
+ * in the JSP.
+ * @return mapping status
+ */
+ public boolean isMapped() {
+ return mapped;
+ }
+
+ /**
+ * If true, generate separate write() calls for each HTML line
+ * in the JSP.
+ * @param mapped a <code>boolean</code> value.
+ */
+ public void setMapped(boolean mapped) {
+ this.mapped = mapped;
+ }
+
+ /**
+ * The URI context of relative URI references in the JSP pages.
+ * If it does not exist then it is derived from the location
+ * of the file relative to the declared or derived value of uriroot.
+ *
+ * @param uribase The new Uribase value
+ */
+ public void setUribase(File uribase) {
+ log("Uribase is currently an unused parameter", Project.MSG_WARN);
+ }
+
+ /**
+ * Get the uri base value.
+ * @return the value.
+ */
+ public File getUribase() {
+ return uriroot;
+ }
+
+ /**
+ * The root directory that uri files should be resolved
+ * against. (Default is the directory jspc is invoked from)
+ *
+ * @param uriroot The new Uribase value
+ */
+ public void setUriroot(File uriroot) {
+ this.uriroot = uriroot;
+ }
+
+ /**
+ * Get the uri root value.
+ * @return the value.
+ */
+ public File getUriroot() {
+ return uriroot;
+ }
+
+
+ /**
+ * Set the classpath to be used for this compilation.
+ * @param cp the path to be used.
+ */
+ public void setClasspath(Path cp) {
+ if (classpath == null) {
+ classpath = cp;
+ } else {
+ classpath.append(cp);
+ }
+ }
+
+ /**
+ * Adds a path to the classpath.
+ * @return a path to be configured.
+ */
+ public Path createClasspath() {
+ if (classpath == null) {
+ classpath = new Path(getProject());
+ }
+ return classpath.createPath();
+ }
+
+ /**
+ * Adds a reference to a classpath defined elsewhere
+ * @param r a reference to a classpath.
+ */
+ public void setClasspathRef(Reference r) {
+ createClasspath().setRefid(r);
+ }
+
+ /**
+ * Get the classpath.
+ * @return the classpath.
+ */
+ public Path getClasspath() {
+ return classpath;
+ }
+
+ /**
+ * Set the classpath to be used to find this compiler adapter
+ * @param cp the compiler classpath.
+ */
+ public void setCompilerclasspath(Path cp) {
+ if (compilerClasspath == null) {
+ compilerClasspath = cp;
+ } else {
+ compilerClasspath.append(cp);
+ }
+ }
+
+ /**
+ * get the classpath used to find the compiler adapter
+ * @return the compiler classpath.
+ */
+ public Path getCompilerclasspath() {
+ return compilerClasspath;
+ }
+
+ /**
+ * Support nested compiler classpath, used to locate compiler adapter
+ * @return a path to be configured.
+ */
+ public Path createCompilerclasspath() {
+ if (compilerClasspath == null) {
+ compilerClasspath = new Path(getProject());
+ }
+ return compilerClasspath.createPath();
+ }
+
+ /**
+ * Filename for web.xml.
+ *
+ * @param webxml The new Webxml value
+ */
+ public void setWebxml(File webxml) {
+ this.webxml = webxml;
+ }
+
+ /**
+ * Filename for web.xml.
+ * @return The filename for web.xml.
+ */
+ public File getWebxml() {
+ return this.webxml;
+ }
+
+ /**
+ * output filename for the fraction of web.xml that lists
+ * servlets.
+ * @param webinc The new Webinc value
+ */
+ public void setWebinc(File webinc) {
+ this.webinc = webinc;
+ }
+
+ /**
+ * Get the webinc attribute.
+ * @return the webinc attribute.
+ */
+ public File getWebinc() {
+ return this.webinc;
+ }
+
+ /**
+ * Adds a single webapp.
+ *
+ * @param webappParam add a web app parameter
+ * @throws BuildException if more than one webapp is specified.
+ */
+ public void addWebApp(WebAppParameter webappParam)
+ throws BuildException {
+ //demand create vector of filesets
+ if (webApp == null) {
+ webApp = webappParam;
+ } else {
+ throw new BuildException("Only one webapp can be specified");
+ }
+ }
+
+ /**
+ * Get the web app.
+ * @return the web app attribute.
+ */
+ public WebAppParameter getWebApp() {
+ return webApp;
+ }
+
+ /**
+ * Class name of a JSP compiler adapter.
+ * @param compiler the compiler class name.
+ */
+ public void setCompiler(String compiler) {
+ this.compilerName = compiler;
+ }
+
+ /**
+ * get the list of files to compile
+ * @return the list of files.
+ */
+ public Vector getCompileList() {
+ return compileList;
+ }
+
+ /**
+ * execute by building up a list of files that
+ * have changed and hand them off to a jsp compiler
+ * @throws BuildException on error.
+ */
+ public void execute()
+ throws BuildException {
+
+ // make sure that we've got a destdir
+ if (destDir == null) {
+ throw new BuildException("destdir attribute must be set!",
+ getLocation());
+ }
+
+ if (!destDir.isDirectory()) {
+ throw new BuildException("destination directory \"" + destDir
+ + "\" does not exist or is not a directory",
+ getLocation());
+ }
+
+ File dest = getActualDestDir();
+
+ AntClassLoader al = null;
+ try {
+ //bind to a compiler
+ JspCompilerAdapter compiler =
+ JspCompilerAdapterFactory
+ .getCompiler(compilerName, this,
+ al = getProject().createClassLoader(compilerClasspath));
+
+ //if we are a webapp, hand off to the compiler, which had
+ //better handle it
+ if (webApp != null) {
+ doCompilation(compiler);
+ return;
+ }
+
+ // make sure that we've got a srcdir
+ if (src == null) {
+ throw new BuildException("srcdir attribute must be set!",
+ getLocation());
+ }
+ String [] list = src.list();
+ if (list.length == 0) {
+ throw new BuildException("srcdir attribute must be set!",
+ getLocation());
+ }
+
+
+ // if the compiler does its own dependency stuff, we just
+ // call it right now
+ if (compiler.implementsOwnDependencyChecking()) {
+ doCompilation(compiler);
+ return;
+ }
+
+ //the remainder of this method is only for compilers that
+ //need their dependency work done
+ JspMangler mangler = compiler.createMangler();
+
+ // scan source directories and dest directory to build up both copy
+ // lists and compile lists
+ resetFileLists();
+ int filecount = 0;
+ for (int i = 0; i < list.length; i++) {
+ File srcDir = getProject().resolveFile(list[i]);
+ if (!srcDir.exists()) {
+ throw new BuildException("srcdir \"" + srcDir.getPath()
+ + "\" does not exist!",
+ getLocation());
+ }
+ DirectoryScanner ds = this.getDirectoryScanner(srcDir);
+ String[] files = ds.getIncludedFiles();
+ filecount = files.length;
+ scanDir(srcDir, dest, mangler, files);
+ }
+
+ // compile the source files
+
+ log("compiling " + compileList.size() + " files",
+ Project.MSG_VERBOSE);
+
+ if (compileList.size() > 0) {
+
+ log("Compiling " + compileList.size() + " source file"
+ + (compileList.size() == 1 ? "" : "s")
+ + " to "
+ + dest);
+ doCompilation(compiler);
+
+ } else {
+ if (filecount == 0) {
+ log("there were no files to compile", Project.MSG_INFO);
+ } else {
+ log("all files are up to date", Project.MSG_VERBOSE);
+ }
+ }
+ } finally {
+ if (al != null) {
+ al.cleanup();
+ }
+ }
+ }
+
+ /**
+ * calculate where the files will end up:
+ * this is destDir or it id destDir + the package name
+ */
+ private File getActualDestDir() {
+ File dest = null;
+ if (packageName == null) {
+ dest = destDir;
+ } else {
+ String path = destDir.getPath() + File.separatorChar
+ + packageName.replace('.', File.separatorChar);
+ dest = new File(path);
+ }
+ return dest;
+ }
+
+ /**
+ * do the compile
+ */
+ private void doCompilation(JspCompilerAdapter compiler)
+ throws BuildException {
+ // now we need to populate the compiler adapter
+ compiler.setJspc(this);
+
+ // finally, lets execute the compiler!!
+ if (!compiler.execute()) {
+ if (failOnError) {
+ throw new BuildException(FAIL_MSG, getLocation());
+ } else {
+ log(FAIL_MSG, Project.MSG_ERR);
+ }
+ }
+ }
+
+ /**
+ * Clear the list of files to be compiled and copied..
+ */
+ protected void resetFileLists() {
+ compileList.removeAllElements();
+ }
+
+ /**
+ * Scans the directory looking for source files to be compiled.
+ * The results are returned in the class variable compileList
+ * @param srcDir the source directory.
+ * @param dest the destination directory.
+ * @param mangler the jsp filename mangler.
+ * @param files the file names to mangle.
+ */
+ protected void scanDir(File srcDir, File dest, JspMangler mangler,
+ String[] files) {
+
+ long now = (new Date()).getTime();
+
+ for (int i = 0; i < files.length; i++) {
+ String filename = files[i];
+ File srcFile = new File(srcDir, filename);
+ File javaFile = mapToJavaFile(mangler, srcFile, srcDir, dest);
+ if (javaFile == null) {
+ continue;
+ }
+
+ if (srcFile.lastModified() > now) {
+ log("Warning: file modified in the future: " + filename,
+ Project.MSG_WARN);
+ }
+ boolean shouldCompile = false;
+ shouldCompile = isCompileNeeded(srcFile, javaFile);
+ if (shouldCompile) {
+ compileList.addElement(srcFile.getAbsolutePath());
+ javaFiles.addElement(javaFile);
+ }
+ }
+ }
+
+ /**
+ * Test whether or not compilation is needed. A return value of
+ * <code>true<code> means yes, <code>false</code> means
+ * our tests do not indicate this, but as the TLDs are
+ * not used for dependency checking this is not guaranteed.
+ * The current tests are
+ * <ol>
+ * <li>no dest file
+ * <li>dest file out of date w.r.t source
+ * <li>dest file zero bytes long
+ * </ol>
+ * @param srcFile JSP source file
+ * @param javaFile JSP dest file
+ * @return true if a compile is definitely needed.
+ *
+ */
+ private boolean isCompileNeeded(File srcFile, File javaFile) {
+ boolean shouldCompile = false;
+ if (!javaFile.exists()) {
+ shouldCompile = true;
+ log("Compiling " + srcFile.getPath()
+ + " because java file " + javaFile.getPath()
+ + " does not exist", Project.MSG_VERBOSE);
+ } else {
+ if (srcFile.lastModified() > javaFile.lastModified()) {
+ shouldCompile = true;
+ log("Compiling " + srcFile.getPath()
+ + " because it is out of date with respect to "
+ + javaFile.getPath(),
+ Project.MSG_VERBOSE);
+ } else {
+ if (javaFile.length() == 0) {
+ shouldCompile = true;
+ log("Compiling " + srcFile.getPath()
+ + " because java file " + javaFile.getPath()
+ + " is empty", Project.MSG_VERBOSE);
+ }
+ }
+ }
+ return shouldCompile;
+ }
+
+
+ /**
+ * get a filename from our jsp file.
+ * @param mangler the jsp filename manager.
+ * @param srcFile the source file.
+ * @param srcDir the source directory.
+ * @param dest the destination directory.
+ * @return the filename.
+ * @todo support packages and subdirs
+ */
+ protected File mapToJavaFile(JspMangler mangler, File srcFile, File srcDir,
+ File dest) {
+ if (!srcFile.getName().endsWith(".jsp")) {
+ return null;
+ }
+ String javaFileName = mangler.mapJspToJavaName(srcFile);
+ // String srcFileDir=srcFile.getParent();
+ return new File(dest, javaFileName);
+ }
+
+ /**
+ * delete any java output files that are empty
+ * this is to get around a little defect in jasper: when it
+ * fails, it leaves incomplete files around.
+ */
+ public void deleteEmptyJavaFiles() {
+ if (javaFiles != null) {
+ Enumeration e = javaFiles.elements();
+ while (e.hasMoreElements()) {
+ File file = (File) e.nextElement();
+ if (file.exists() && file.length() == 0) {
+ log("deleting empty output file " + file);
+ file.delete();
+ }
+ }
+ }
+ }
+
+ /**
+ * static inner class used as a parameter element
+ */
+ public static class WebAppParameter {
+
+ /**
+ * the sole option
+ */
+ private File directory;
+
+ /**
+ * query current directory
+ * @return the directory.
+ */
+ public File getDirectory() {
+ return directory;
+ }
+
+ /**
+ * set directory; alternate syntax
+ * @param directory the base dir.
+ */
+ public void setBaseDir(File directory) {
+ this.directory = directory;
+ }
+ //end inner class
+ }
+
+
+ //end class
+}
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspMangler.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspMangler.java
new file mode 100644
index 00000000..f62492c3
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspMangler.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.optional.jsp;
+
+import java.io.File;
+
+/**
+ * This is an interface to the Mangler service that jspc needs to map
+ * JSP file names to java files.
+ * Note the complete lack of correlation
+ * with Jasper's mangler interface.
+ */
+public interface JspMangler {
+
+
+ /**
+ * map from a jsp file to a java filename; does not do packages
+ *
+ * @param jspFile file
+ * @return java filename
+ */
+ String mapJspToJavaName(File jspFile);
+
+ /**
+ * taking in the substring representing the path relative to the source dir
+ * return a new string representing the destination path
+ * @param path the path to map.
+ * @return the mapped path.
+ */
+ String mapPath(String path);
+
+}
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java
new file mode 100644
index 00000000..6e08e7d5
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspNameMangler.java
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.optional.jsp;
+import java.io.File;
+
+import org.apache.tools.ant.util.StringUtils;
+
+/**
+ * This is a class derived from the Jasper code
+ * (org.apache.jasper.compiler.CommandLineCompiler) to map from a JSP filename
+ * to a valid Java classname.
+ *
+ */
+public class JspNameMangler implements JspMangler {
+
+ // CheckStyle:ConstantNameCheck OFF - bc
+
+ /**
+ * this is the list of keywords which can not be used as classnames
+ */
+ public static final String[] keywords = {
+ "assert",
+ "abstract", "boolean", "break", "byte",
+ "case", "catch", "char", "class",
+ "const", "continue", "default", "do",
+ "double", "else", "extends", "final",
+ "finally", "float", "for", "goto",
+ "if", "implements", "import",
+ "instanceof", "int", "interface",
+ "long", "native", "new", "package",
+ "private", "protected", "public",
+ "return", "short", "static", "super",
+ "switch", "synchronized", "this",
+ "throw", "throws", "transient",
+ "try", "void", "volatile", "while"
+ };
+
+ // CheckStyle:ConstantNameCheck ON
+
+ /**
+ * map from a jsp file to a java filename; does not do packages
+ *
+ * @param jspFile file
+ * @return java filename
+ */
+ public String mapJspToJavaName(File jspFile) {
+ return mapJspToBaseName(jspFile) + ".java";
+ }
+
+
+ /**
+ * map from a jsp file to a base name; does not deal with extensions
+ *
+ * @param jspFile jspFile file
+ * @return exensionless potentially remapped name
+ */
+ private String mapJspToBaseName(File jspFile) {
+ String className;
+ className = stripExtension(jspFile);
+
+ // since we don't mangle extensions like the servlet does,
+ // we need to check for keywords as class names
+ for (int i = 0; i < keywords.length; ++i) {
+ if (className.equals(keywords[i])) {
+ className += "%";
+ break;
+ }
+ }
+
+ // Fix for invalid characters. If you think of more add to the list.
+ StringBuffer modifiedClassName = new StringBuffer(className.length());
+ // first char is more restrictive than the rest
+ char firstChar = className.charAt(0);
+ if (Character.isJavaIdentifierStart(firstChar)) {
+ modifiedClassName.append(firstChar);
+ } else {
+ modifiedClassName.append(mangleChar(firstChar));
+ }
+ // this is the rest
+ for (int i = 1; i < className.length(); i++) {
+ char subChar = className.charAt(i);
+ if (Character.isJavaIdentifierPart(subChar)) {
+ modifiedClassName.append(subChar);
+ } else {
+ modifiedClassName.append(mangleChar(subChar));
+ }
+ }
+ return modifiedClassName.toString();
+ }
+
+
+ /**
+ * get short filename from file
+ *
+ * @param jspFile file in
+ * @return file without any jsp extension
+ */
+ private String stripExtension(File jspFile) {
+ return StringUtils.removeSuffix(jspFile.getName(), ".jsp");
+ }
+
+
+ /**
+ * definition of the char escaping algorithm
+ *
+ * @param ch char to mangle
+ * @return mangled string; 5 digit hex value
+ */
+ private static String mangleChar(char ch) {
+ // CheckStyle:MagicNumber OFF
+ if (ch == File.separatorChar) {
+ ch = '/';
+ }
+ String s = Integer.toHexString(ch);
+ int nzeros = 5 - s.length();
+ char[] result = new char[6];
+ result[0] = '_';
+ for (int i = 1; i <= nzeros; ++i) {
+ result[i] = '0';
+ }
+ int resultIndex = 0;
+ for (int i = nzeros + 1; i < 6; ++i) {
+ result[i] = s.charAt(resultIndex++);
+ }
+ return new String(result);
+ // CheckStyle:MagicNumber ON
+ }
+
+ /**
+ * taking in the substring representing the path relative to the source dir
+ * return a new string representing the destination path
+ * not supported, as jasper in tomcat4.0 doesn't either
+ * @param path not used
+ * @return null always.
+ */
+ public String mapPath(String path) {
+ return null;
+ }
+}
+
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
new file mode 100644
index 00000000..45a427ad
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/WLJspc.java
@@ -0,0 +1,334 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.optional.jsp;
+
+//apache/ant imports
+import java.io.File;
+import java.util.Date;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Java;
+import org.apache.tools.ant.taskdefs.MatchingTask;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * Precompiles JSP's using WebLogic's JSP compiler (weblogic.jspc).
+ *
+ * Tested only on Weblogic 4.5.1 - NT4.0 and Solaris 5.7
+ *
+ * required attributes
+ * src : root of source tree for JSP, ie, the document root for your weblogic server
+ * dest : root of destination directory, what you have set as
+ * WorkingDir in the weblogic properties
+ * package : start package name under which your JSP's would be compiled
+ *
+ * other attributes
+ * classpath
+ *
+ * A classpath should be set which contains the weblogic classes as well as all
+ * application classes referenced by the JSP. The system classpath is also
+ * appended when the jspc is called, so you may choose to put everything in
+ * the classpath while calling Ant. However, since presumably the JSP's will
+ * reference classes being build by Ant, it would be better to explicitly add
+ * the classpath in the task
+ *
+ * The task checks timestamps on the JSP's and the generated classes, and compiles
+ * only those files that have changed.
+ *
+ * It follows the weblogic naming convention of putting classes in
+ * <b> _dirName/_fileName.class for dirname/fileName.jsp </b>
+ *
+ * Limitation: It compiles the files thru the Classic compiler only.
+ * Limitation: Since it is my experience that weblogic jspc throws out of
+ * memory error on being given too many files at one go, it is
+ * called multiple times with one jsp file each.
+ *
+ * <pre>
+ * example
+ * &lt;target name="jspcompile" depends="compile"&gt;
+ * &lt;wljspc src="c:\\weblogic\\myserver\\public_html"
+ * dest="c:\\weblogic\\myserver\\serverclasses" package="myapp.jsp"&gt;
+ * &lt;classpath&gt;
+ * &lt;pathelement location="${weblogic.classpath}" /&gt;
+ * &lt;pathelement path="${compile.dest}" /&gt;
+ * &lt;/classpath&gt;
+ *
+ * &lt;/wljspc&gt;
+ * &lt;/target&gt;
+ * </pre>
+ *
+ */
+
+public class WLJspc extends MatchingTask {
+ //TODO Test on other versions of weblogic
+ //TODO add more attributes to the task, to take care of all jspc options
+ //TODO Test on Unix
+
+ /** root of compiled files tree */
+ private File destinationDirectory;
+
+ /** root of source files tree */
+ private File sourceDirectory;
+
+ /** package under which resultant classes will reside */
+ private String destinationPackage;
+
+ /** classpath used to compile the jsp files. */
+ private Path compileClasspath;
+
+ //private String compilerPath; //fully qualified name for the compiler executable
+
+ private String pathToPackage = "";
+ private Vector filesToDo = new Vector();
+
+ /**
+ * Run the task.
+ * @throws BuildException if there is an error.
+ */
+ public void execute() throws BuildException {
+ if (!destinationDirectory.isDirectory()) {
+ throw new BuildException("destination directory "
+ + destinationDirectory.getPath() + " is not valid");
+ }
+
+ if (!sourceDirectory.isDirectory()) {
+ throw new BuildException("src directory "
+ + sourceDirectory.getPath() + " is not valid");
+ }
+
+ if (destinationPackage == null) {
+ throw new BuildException("package attribute must be present.",
+ getLocation());
+ }
+
+
+ pathToPackage
+ = this.destinationPackage.replace('.', File.separatorChar);
+ // get all the files in the sourceDirectory
+ DirectoryScanner ds = super.getDirectoryScanner(sourceDirectory);
+
+ //use the systemclasspath as well, to include the ant jar
+ if (compileClasspath == null) {
+ compileClasspath = new Path(getProject());
+ }
+
+ compileClasspath = compileClasspath.concatSystemClasspath();
+ String[] files = ds.getIncludedFiles();
+
+ //Weblogic.jspc calls System.exit() ... have to fork
+ // Therefore, takes loads of time
+ // Can pass directories at a time (*.jsp) but easily runs out of
+ // memory on hefty dirs (even on a Sun)
+ Java helperTask = new Java(this);
+ helperTask.setFork(true);
+ helperTask.setClassname("weblogic.jspc");
+ helperTask.setTaskName(getTaskName());
+ // CheckStyle:MagicNumber OFF
+ String[] args = new String[12];
+ // CheckStyle:MagicNumber ON
+
+ File jspFile = null;
+ String parents = "";
+ int j = 0;
+ //TODO this array stuff is a remnant of prev trials.. gotta remove.
+ args[j++] = "-d";
+ args[j++] = destinationDirectory.getAbsolutePath().trim();
+ args[j++] = "-docroot";
+ args[j++] = sourceDirectory.getAbsolutePath().trim();
+ args[j++] = "-keepgenerated";
+ //Call compiler as class... dont want to fork again
+ //Use classic compiler -- can be parameterised?
+ args[j++] = "-compilerclass";
+ args[j++] = "sun.tools.javac.Main";
+ //Weblogic jspc does not seem to work unless u explicitly set this...
+ // Does not take the classpath from the env....
+ // Am i missing something about the Java task??
+ args[j++] = "-classpath";
+ args[j++] = compileClasspath.toString();
+
+ this.scanDir(files);
+ log("Compiling " + filesToDo.size() + " JSP files");
+
+ final int size = filesToDo.size();
+ for (int i = 0; i < size; i++) {
+ //TODO
+ // All this to get package according to weblogic standards
+ // Can be written better... this is too hacky!
+ // Careful.. similar code in scanDir , but slightly different!!
+ String filename = (String) filesToDo.elementAt(i);
+ jspFile = new File(filename);
+ args[j] = "-package";
+ parents = jspFile.getParent();
+ if ((parents != null) && (!("").equals(parents))) {
+ parents = this.replaceString(parents, File.separator, "_.");
+ args[j + 1] = destinationPackage + "." + "_" + parents;
+ } else {
+ args[j + 1] = destinationPackage;
+ }
+
+
+ args[j + 2] = sourceDirectory + File.separator + filename;
+ helperTask.clearArgs();
+
+ // CheckStyle:MagicNumber OFF
+ for (int x = 0; x < j + 3; x++) {
+ helperTask.createArg().setValue(args[x]);
+ }
+ // CheckStyle:MagicNumber ON
+
+ helperTask.setClasspath(compileClasspath);
+ if (helperTask.executeJava() != 0) {
+ log(filename + " failed to compile", Project.MSG_WARN);
+ }
+ }
+ }
+
+
+
+ /**
+ * Set the classpath to be used for this compilation.
+ * @param classpath the classpath to use.
+ */
+ public void setClasspath(Path classpath) {
+ if (compileClasspath == null) {
+ compileClasspath = classpath;
+ } else {
+ compileClasspath.append(classpath);
+ }
+ }
+
+ /**
+ * Maybe creates a nested classpath element.
+ * @return a path to be configured.
+ */
+ public Path createClasspath() {
+ if (compileClasspath == null) {
+ compileClasspath = new Path(getProject());
+ }
+ return compileClasspath;
+ }
+
+ /**
+ * Set the directory containing the source jsp's
+ *
+ *
+ * @param dirName the directory containg the source jsp's
+ */
+ public void setSrc(File dirName) {
+
+ sourceDirectory = dirName;
+ }
+
+ /**
+ * Set the directory containing the source jsp's
+ *
+ *
+ * @param dirName the directory containg the source jsp's
+ */
+ public void setDest(File dirName) {
+
+ destinationDirectory = dirName;
+ }
+
+ /**
+ * Set the package under which the compiled classes go
+ *
+ * @param packageName the package name for the classes
+ */
+ public void setPackage(String packageName) {
+
+ destinationPackage = packageName;
+ }
+
+ /**
+ * Scan the array of files and add the jsp
+ * files that need to be compiled to the filesToDo field.
+ * @param files the files to scan.
+ */
+ protected void scanDir(String[] files) {
+
+ long now = (new Date()).getTime();
+ File jspFile = null;
+ String parents = null;
+ String pack = "";
+ for (int i = 0; i < files.length; i++) {
+ File srcFile = new File(this.sourceDirectory, files[i]);
+ //TODO
+ // All this to convert source to destination directory according
+ // to weblogic standards Can be written better... this is too hacky!
+ jspFile = new File(files[i]);
+ parents = jspFile.getParent();
+
+ if ((parents != null) && (!("").equals(parents))) {
+ parents = this.replaceString(parents, File.separator, "_/");
+ pack = pathToPackage + File.separator + "_" + parents;
+ } else {
+ pack = pathToPackage;
+ }
+
+ String filePath = pack + File.separator + "_";
+ int startingIndex = files[i].lastIndexOf(File.separator) != -1
+ ? files[i].lastIndexOf(File.separator) + 1 : 0;
+ int endingIndex = files[i].indexOf(".jsp");
+ if (endingIndex == -1) {
+ log("Skipping " + files[i] + ". Not a JSP",
+ Project.MSG_VERBOSE);
+ continue;
+ }
+
+ filePath += files[i].substring(startingIndex, endingIndex);
+ filePath += ".class";
+ File classFile = new File(this.destinationDirectory, filePath);
+
+ if (srcFile.lastModified() > now) {
+ log("Warning: file modified in the future: "
+ + files[i], Project.MSG_WARN);
+ }
+ if (srcFile.lastModified() > classFile.lastModified()) {
+ filesToDo.addElement(files[i]);
+ log("Recompiling File " + files[i], Project.MSG_VERBOSE);
+ }
+ }
+ }
+
+
+ /**
+ * Replace occurrences of a string with a replacement string.
+ * @param inpString the string to convert.
+ * @param escapeChars the string to replace.
+ * @param replaceChars the string to place.
+ * @return the converted string.
+ */
+ protected String replaceString(String inpString, String escapeChars,
+ String replaceChars) {
+ String localString = "";
+ int numTokens = 0;
+ StringTokenizer st = new StringTokenizer(inpString, escapeChars, true);
+ numTokens = st.countTokens();
+ for (int i = 0; i < numTokens; i++) {
+ String test = st.nextToken();
+ test = (test.equals(escapeChars) ? replaceChars : test);
+ localString += test;
+ }
+ return localString;
+ }
+}
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
new file mode 100644
index 00000000..5c4d0e3b
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/DefaultJspCompilerAdapter.java
@@ -0,0 +1,153 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
+import org.apache.tools.ant.types.CommandlineJava;
+
+/**
+ * This is the default implementation for the JspCompilerAdapter interface.
+ * This is currently very light on the ground since only one compiler type is
+ * supported.
+ *
+ */
+public abstract class DefaultJspCompilerAdapter
+ implements JspCompilerAdapter {
+
+ private static String lSep = System.getProperty("line.separator");
+
+ /**
+ * Logs the compilation parameters, adds the files to compile and logs the
+ * &quot;niceSourceList&quot;
+ * @param jspc the compiler task for logging
+ * @param compileList the list of files to compile
+ * @param cmd the command line used
+ */
+ protected void logAndAddFilesToCompile(JspC jspc,
+ Vector compileList,
+ CommandlineJava cmd) {
+ jspc.log("Compilation " + cmd.describeJavaCommand(),
+ Project.MSG_VERBOSE);
+
+ StringBuffer niceSourceList = new StringBuffer("File");
+ if (compileList.size() != 1) {
+ niceSourceList.append("s");
+ }
+ niceSourceList.append(" to be compiled:");
+
+ niceSourceList.append(lSep);
+
+ Enumeration e = compileList.elements();
+ while (e.hasMoreElements()) {
+ String arg = (String) e.nextElement();
+ cmd.createArgument().setValue(arg);
+ niceSourceList.append(" ");
+ niceSourceList.append(arg);
+ niceSourceList.append(lSep);
+ }
+
+ jspc.log(niceSourceList.toString(), Project.MSG_VERBOSE);
+ }
+
+ // CheckStyle:VisibilityModifier OFF - bc
+
+ /**
+ * our owner
+ */
+ protected JspC owner;
+
+ // CheckStyle:VisibilityModifier ON
+
+ /**
+ * set the owner
+ * @param owner the owner JspC compiler
+ */
+ public void setJspc(JspC owner) {
+ this.owner = owner;
+ }
+
+ /** get the owner
+ * @return the owner; should never be null
+ */
+ public JspC getJspc() {
+ return owner;
+ }
+
+
+ /**
+ * add an argument oneple to the argument list, if the value aint null
+ * @param cmd the command line
+ * @param argument The argument
+ */
+ protected void addArg(CommandlineJava cmd, String argument) {
+ if (argument != null && argument.length() != 0) {
+ cmd.createArgument().setValue(argument);
+ }
+ }
+
+
+ /**
+ * add an argument tuple to the argument list, if the value aint null
+ * @param cmd the command line
+ * @param argument The argument
+ * @param value the parameter
+ */
+ protected void addArg(CommandlineJava cmd, String argument, String value) {
+ if (value != null) {
+ cmd.createArgument().setValue(argument);
+ cmd.createArgument().setValue(value);
+ }
+ }
+
+ /**
+ * add an argument tuple to the arg list, if the file parameter aint null
+ * @param cmd the command line
+ * @param argument The argument
+ * @param file the parameter
+ */
+ protected void addArg(CommandlineJava cmd, String argument, File file) {
+ if (file != null) {
+ cmd.createArgument().setValue(argument);
+ cmd.createArgument().setFile(file);
+ }
+ }
+
+ /**
+ * ask if compiler can sort out its own dependencies
+ * @return true if the compiler wants to do its own
+ * depends
+ */
+ public boolean implementsOwnDependencyChecking() {
+ return false;
+ }
+
+ /**
+ * get our project
+ * @return owner project data
+ */
+ public Project getProject() {
+ return getJspc().getProject();
+ }
+}
+
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
new file mode 100644
index 00000000..f0becacb
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JasperC.java
@@ -0,0 +1,182 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+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;
+import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
+import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler;
+import org.apache.tools.ant.types.CommandlineJava;
+import org.apache.tools.ant.types.Path;
+
+/**
+ * The implementation of the jasper compiler.
+ * This is a cut-and-paste of the original Jspc task.
+ *
+ * @since ant1.5
+ */
+public class JasperC extends DefaultJspCompilerAdapter {
+
+ // CheckStyle:VisibilityModifier OFF - bc
+
+ /**
+ * what produces java classes from .jsp files
+ */
+ JspMangler mangler;
+
+ // CheckStyle:VisibilityModifier ON
+
+ /**
+ * Constructor for JasperC.
+ * @param mangler a filename converter
+ */
+ public JasperC(JspMangler mangler) {
+ this.mangler = mangler;
+ }
+
+ /**
+ * Our execute method.
+ * @return true if successful
+ * @throws BuildException on error
+ */
+ public boolean execute()
+ throws BuildException {
+ 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 = new Java(owner);
+ Path p = getClasspath();
+ if (getJspc().getClasspath() != null) {
+ getProject().log("using user supplied classpath: " + p,
+ Project.MSG_DEBUG);
+ } else {
+ getProject().log("using system classpath: " + p,
+ Project.MSG_DEBUG);
+ }
+ java.setClasspath(p);
+ java.setDir(getProject().getBaseDir());
+ java.setClassname("org.apache.jasper.JspC");
+ //this is really irritating; we need a way to set stuff
+ String []args = cmd.getJavaCommand().getArguments();
+ for (int i = 0; i < args.length; i++) {
+ java.createArg().setValue(args[i]);
+ }
+ java.setFailonerror(getJspc().getFailonerror());
+ //we are forking here to be sure that if JspC calls
+ //System.exit() it doesn't halt the build
+ java.setFork(true);
+ java.setTaskName("jasperc");
+ java.execute();
+ return true;
+ } catch (Exception ex) {
+ if (ex instanceof BuildException) {
+ throw (BuildException) ex;
+ } else {
+ throw new BuildException("Error running jsp compiler: ",
+ ex, getJspc().getLocation());
+ }
+ } finally {
+ getJspc().deleteEmptyJavaFiles();
+ }
+ }
+
+
+
+ /**
+ * build up a command line
+ * @return a command line for jasper
+ */
+ private CommandlineJava setupJasperCommand() {
+ CommandlineJava cmd = new CommandlineJava();
+ JspC jspc = getJspc();
+ addArg(cmd, "-d", jspc.getDestdir());
+ addArg(cmd, "-p", jspc.getPackage());
+
+ 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());
+ addArg(cmd, "-webinc", jspc.getWebinc());
+ addArg(cmd, "-webxml", jspc.getWebxml());
+ addArg(cmd, "-die9");
+
+ if (jspc.isMapped()) {
+ addArg(cmd, "-mapped");
+ }
+ if (jspc.getWebApp() != null) {
+ File dir = jspc.getWebApp().getDirectory();
+ addArg(cmd, "-webapp", dir);
+ }
+ logAndAddFilesToCompile(getJspc(), getJspc().getCompileList(), cmd);
+ return cmd;
+ }
+
+ /**
+ * @return an instance of the mangler this compiler uses
+ */
+
+ 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();
+ }
+ }
+ }
+}
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java
new file mode 100644
index 00000000..16b67f9d
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapter.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.optional.jsp.JspC;
+import org.apache.tools.ant.taskdefs.optional.jsp.JspMangler;
+
+/**
+ * The interface that all jsp compiler adapters must adher to.
+ *
+ * <p>A compiler adapter is an adapter that interprets the jspc's
+ * parameters in preparation to be passed off to the compiler this
+ * adapter represents. As all the necessary values are stored in the
+ * Jspc task itself, the only thing all adapters need is the jsp
+ * task, the execute command and a parameterless constructor (for
+ * reflection).</p>
+ *
+ */
+
+public interface JspCompilerAdapter {
+
+ /**
+ * Sets the compiler attributes, which are stored in the Jspc task.
+ * @param attributes the jsp compiler attributes
+ */
+ void setJspc(JspC attributes);
+
+ /**
+ * Executes the task.
+ *
+ * @return has the compilation been successful
+ * @throws BuildException on error
+ */
+ boolean execute() throws BuildException;
+
+ /**
+ * @return an instance of the mangler this compiler uses
+ */
+
+ JspMangler createMangler();
+
+ /**
+ * ask if compiler can sort out its own dependencies
+ * @return true if the compiler wants to do its own
+ * depends
+ */
+ boolean implementsOwnDependencyChecking();
+}
diff --git a/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java
new file mode 100644
index 00000000..2876ba0c
--- /dev/null
+++ b/framework/src/ant/apache-ant-1.9.6/src/main/org/apache/tools/ant/taskdefs/optional/jsp/compilers/JspCompilerAdapterFactory.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
+
+import org.apache.tools.ant.AntClassLoader;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.optional.jsp.Jasper41Mangler;
+import org.apache.tools.ant.taskdefs.optional.jsp.JspNameMangler;
+
+
+/**
+ * Creates the necessary compiler adapter, given basic criteria.
+ *
+ */
+public final class JspCompilerAdapterFactory {
+
+ /** This is a singleton -- can't create instances!! */
+ private JspCompilerAdapterFactory() {
+ }
+
+ /**
+ * Based on the parameter passed in, this method creates the necessary
+ * factory desired.
+ *
+ * The current mapping for compiler names are as follows:
+ * <ul><li>jasper = jasper compiler (the default)
+ * <li><i>a fully qualified classname</i> = the name of a jsp compiler
+ * adapter
+ * </ul>
+ *
+ * @param compilerType either the name of the desired compiler, or the
+ * full classname of the compiler's adapter.
+ * @param task a task to log through.
+ * @return the compiler
+ * @throws BuildException if the compiler type could not be resolved into
+ * a compiler adapter.
+ */
+ public static JspCompilerAdapter getCompiler(String compilerType, Task task)
+ throws BuildException {
+ return getCompiler(compilerType, task,
+ // Memory-Leak in line below
+ task.getProject().createClassLoader(null));
+ }
+
+ /**
+ * Based on the parameter passed in, this method creates the necessary
+ * factory desired.
+ *
+ * The current mapping for compiler names are as follows:
+ * <ul><li>jasper = jasper compiler (the default)
+ * <li><i>a fully qualified classname</i> = the name of a jsp compiler
+ * adapter
+ * </ul>
+ *
+ * @param compilerType either the name of the desired compiler, or the
+ * full classname of the compiler's adapter.
+ * @param task a task to log through.
+ * @param loader AntClassLoader with which the compiler should be loaded
+ * @return the compiler
+ * @throws BuildException if the compiler type could not be resolved into
+ * a compiler adapter.
+ */
+ public static JspCompilerAdapter getCompiler(String compilerType, Task task,
+ AntClassLoader loader)
+ throws BuildException {
+
+ if (compilerType.equalsIgnoreCase("jasper")) {
+ //tomcat4.0 gets the old mangler
+ return new JasperC(new JspNameMangler());
+ }
+ if (compilerType.equalsIgnoreCase("jasper41")) {
+ //tomcat4.1 gets the new one
+ return new JasperC(new Jasper41Mangler());
+ }
+ return resolveClassName(compilerType, loader);
+ }
+
+ /**
+ * Tries to resolve the given classname into a compiler adapter.
+ * Throws a fit if it can't.
+ *
+ * @param className The fully qualified classname to be created.
+ * @param classloader Classloader with which to load the class
+ * @throws BuildException This is the fit that is thrown if className
+ * isn't an instance of JspCompilerAdapter.
+ */
+ private static JspCompilerAdapter resolveClassName(String className,
+ AntClassLoader classloader)
+ throws BuildException {
+ try {
+ Class c = classloader.findClass(className);
+ Object o = c.newInstance();
+ return (JspCompilerAdapter) o;
+ } catch (ClassNotFoundException cnfe) {
+ throw new BuildException(className + " can\'t be found.", cnfe);
+ } catch (ClassCastException cce) {
+ throw new BuildException(className + " isn\'t the classname of "
+ + "a compiler adapter.", cce);
+ } catch (Throwable t) {
+ // for all other possibilities
+ throw new BuildException(className + " caused an interesting "
+ + "exception.", t);
+ }
+ }
+
+}