keith 02/05/21 11:15:02 Modified: . build.xml src/share/org/apache/tomcat/ant Tomcat3JSPVersionFile.java Log: tomcat-ant changes: - move ant.properties to META-INF - add regexpclasspath attribute to version task Revision Changes Path 1.180 +3 -2 jakarta-tomcat/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/jakarta-tomcat/build.xml,v retrieving revision 1.179 retrieving revision 1.180 diff -u -r1.179 -r1.180 --- build.xml 18 May 2002 17:17:13 -0000 1.179 +++ build.xml 21 May 2002 18:15:02 -0000 1.180 @@ -606,6 +606,7 @@ <!-- ==================== Ant utilities ========== --> <target name="tomcat-ant" depends="detect" if="ant15-present" > + <delete dir="${tomcat.build}/ant" /> <javac srcdir="src/share" destdir="${tomcat.build}/classes" > <include name="org/apache/tomcat/ant/*.java" /> @@ -618,12 +619,12 @@ <mkdir dir="${tomcat.build}/ant" /> <jar jarfile="${tomcat.build}/ant/tomcat-ant.jar" basedir="${tomcat.build}/classes"> - <include name="org/apache/tomcat/ant/**" /> + <include name="org/apache/tomcat/ant/*.class" /> </jar> <jar jarfile="${tomcat.build}/ant/tomcat-ant.jar" basedir="src/share/org/apache/tomcat/ant" update="yes"> - <include name="*.properties" /> + <include name="META-INF/*.properties" /> </jar> </target> 1.2 +66 -3 jakarta-tomcat/src/share/org/apache/tomcat/ant/Tomcat3JSPVersionFile.java Index: Tomcat3JSPVersionFile.java =================================================================== RCS file: /home/cvs/jakarta-tomcat/src/share/org/apache/tomcat/ant/Tomcat3JSPVersionFile.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- Tomcat3JSPVersionFile.java 16 May 2002 03:15:13 -0000 1.1 +++ Tomcat3JSPVersionFile.java 21 May 2002 18:15:02 -0000 1.2 @@ -59,10 +59,13 @@ import java.io.FileInputStream; import java.io.IOException; 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.Task; +import org.apache.tools.ant.types.Path; +import org.apache.tools.ant.types.Reference; import org.apache.tools.ant.util.regexp.RegexpMatcher; import org.apache.tools.ant.util.regexp.RegexpMatcherFactory; @@ -70,9 +73,11 @@ * Task to create version files used by Tomcat to determine the * appropriate class to load for a JSP. * - * This task can accept the following attribute: + * This task can accept the following attributes: * <ul> * <li>srcdir + * <li>regexpclasspath + * <li>regexpclasspathref * </ul> * <b>srcdir</b> is required. * <p> @@ -83,18 +88,24 @@ * it contains the correct version <i>nnn</i>. If not, a new version file is * created. * + * <p>This task uses a regular expression library. If one is not found in + * the ant classpath, this task will attempt to load both the Ant regexp + * bridge (optional.jar) and the Jakarta regular expression matcher + * (jakarta-regexp) from the specified regexpclasspath. + * * <p>Use this task with the Tomcat3Precompiler to create the appropriate * files to pre-populate the Tomcat work directory. * * @author Keith Wannamaker <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ * * @since Ant 1.6 * */ public class Tomcat3JSPVersionFile extends Task { private File srcdir; + private Path regexpClasspath; private RegexpMatcherFactory factory = new RegexpMatcherFactory(); /** Setter for srcdir */ @@ -102,6 +113,32 @@ this.srcdir = new File(srcdir); } + /** Setter for regexpclasspath */ + public void setRegexpClasspath(Path cp) { + if (regexpClasspath == null) { + regexpClasspath = cp; + } else { + regexpClasspath.append(cp); + } + } + + /** + * Support nested regexpclasspath elements + */ + public Path createRegexpClasspath() { + if (regexpClasspath == null) { + regexpClasspath = new Path(project); + } + return regexpClasspath.createPath(); + } + + /** + * Add classpath reference + */ + public void setRegexpClasspathRef(Reference r) { + createRegexpClasspath().setRefid(r); + } + /** Execute the task */ public void execute() throws BuildException { if (srcdir == null) { @@ -115,7 +152,7 @@ String[] files = ds.getIncludedFiles(); int count = 0; for (int i = 0; i < files.length; i++) { - RegexpMatcher rm = factory.newRegexpMatcher(); + RegexpMatcher rm = loadRegexpMatcher(); rm.setPattern("(.*)_(\\d*).class"); if (rm.matches(files[i])) { Vector components = rm.getGroups(files[i]); @@ -165,5 +202,31 @@ } } + /** + * Load regexp matcher + */ + private RegexpMatcher loadRegexpMatcher() throws BuildException { + RegexpMatcher rm; + /* First try to load from factory's classloader */ + try { + rm = factory.newRegexpMatcher(); + log("Loaded RegexpMatcher from factory", Project.MSG_DEBUG); + return rm; + } catch (BuildException be) { + ; + } + /* Now try to load the Jakara regexp jar from a specified classpath */ + try { + log("Loading RegexpMatcher from " + regexpClasspath, Project.MSG_DEBUG); + AntClassLoader loader = new AntClassLoader(getProject(), regexpClasspath); + Class implClass = loader.findClass(DEFAULT_REGEXP_CLASS); + return (RegexpMatcher) implClass.newInstance(); + } catch (Throwable t) { + throw new BuildException(t); + } + } + + protected String DEFAULT_REGEXP_CLASS = + "org.apache.tools.ant.util.regexp.JakartaRegexpMatcher"; }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>