bodewig 2004/06/25 06:50:16 Modified: . Tag: ANT_16_BRANCH TODO WHATSNEW build.xml docs Tag: ANT_16_BRANCH faq.html docs/manual/OptionalTasks Tag: ANT_16_BRANCH junitreport.html src/etc Tag: ANT_16_BRANCH junit-frames.xsl src/main/org/apache/tools/ant/taskdefs/optional/junit Tag: ANT_16_BRANCH Xalan1Executor.java Xalan2Executor.java XalanExecutor.java xdocs Tag: ANT_16_BRANCH faq.xml Added: src/etc Tag: ANT_16_BRANCH junit-frames-xalan1.xsl Log: typos Revision Changes Path No revision No revision 1.3.2.23 +0 -3 ant/Attic/TODO Index: TODO =================================================================== RCS file: /home/cvs/ant/Attic/TODO,v retrieving revision 1.3.2.22 retrieving revision 1.3.2.23 diff -u -r1.3.2.22 -r1.3.2.23 --- TODO 23 Jun 2004 19:17:11 -0000 1.3.2.22 +++ TODO 25 Jun 2004 13:50:16 -0000 1.3.2.23 @@ -9,9 +9,6 @@ * review claimed AntClassLoader memory leak [Stefan] -* <junitreport> and JDK 1.5 [Stefan hopes that Stephane solves it for - him, otherwise he'll do it himself] - * AntClassLoader parent loader [Start thread, Peter] * delete - do not follow symlinks [Peter, may be dropped for 1.6.2] 1.503.2.114 +14 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.503.2.113 retrieving revision 1.503.2.114 diff -u -r1.503.2.113 -r1.503.2.114 --- WHATSNEW 23 Jun 2004 19:17:11 -0000 1.503.2.113 +++ WHATSNEW 25 Jun 2004 13:50:16 -0000 1.503.2.114 @@ -17,6 +17,17 @@ * Nested elements for namespaced tasks and types may belong to the Ant default namespace as well as the task's or type's namespace. +* <junitreport> will very likely no longer work with Xalan-J 1. + + Note that Xalan-J 1 has been deprecated for a very long time and we + highly recommend that you upgrade. + + If you really need to continue using Xalan-J 1, please copy the + junit-frames-xalan1.xsl from the distribution's etc directory as + junit-frames.xsl into a new directory and use the task's styledir + attribute to point to. This is the last version of the XSLT + stylesheet that is expected to be compatible with Xalan-J 1. + Fixed bugs: ----------- @@ -217,6 +228,9 @@ * <apply> has a new ignoremissing attribute (default true for BC) which will allow nonexistent files specified via <filelist>s to be passed to the executable. Bugzilla Report 29585. + +* <junitreport> now also works with Xalan XSLTC and/or JDK 1.5. + Bugzilla Report 27541. Changes from Ant 1.6.0 to Ant 1.6.1 ============================================= 1.392.2.30 +1 -0 ant/build.xml Index: build.xml =================================================================== RCS file: /home/cvs/ant/build.xml,v retrieving revision 1.392.2.29 retrieving revision 1.392.2.30 diff -u -r1.392.2.29 -r1.392.2.30 --- build.xml 2 Jun 2004 12:10:59 -0000 1.392.2.29 +++ build.xml 25 Jun 2004 13:50:16 -0000 1.392.2.30 @@ -1031,6 +1031,7 @@ <fileset dir="${etc.dir}"> <include name="junit-frames.xsl"/> <include name="junit-noframes.xsl"/> + <include name="junit-frames-xalan1.xsl"/> <include name="coverage-frames.xsl"/> <include name="maudit-frames.xsl"/> <include name="mmetrics-frames.xsl"/> No revision No revision 1.77.2.15 +2 -2 ant/docs/faq.html Index: faq.html =================================================================== RCS file: /home/cvs/ant/docs/faq.html,v retrieving revision 1.77.2.14 retrieving revision 1.77.2.15 diff -u -r1.77.2.14 -r1.77.2.15 --- faq.html 16 Jun 2004 14:27:27 -0000 1.77.2.14 +++ faq.html 25 Jun 2004 13:50:16 -0000 1.77.2.15 @@ -1669,8 +1669,8 @@ extensions for its internal stylesheet, Ant doesn't support XSLTC yet. This means that you have to install <a href="http://xml.apache.org/xalan-j/">Xalan-J 2</a> in order to use this task with JDK 1.5.</p> - <p>If you want to follow progress on this, <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=27541">here</a> - is the relevant bug report.</p> + <p>Starting with Ant 1.6.2 <code><junitreport></code> + will support JDK 1.5.</p> </div> </div> No revision No revision 1.11.2.4 +19 -15 ant/docs/manual/OptionalTasks/junitreport.html Index: junitreport.html =================================================================== RCS file: /home/cvs/ant/docs/manual/OptionalTasks/junitreport.html,v retrieving revision 1.11.2.3 retrieving revision 1.11.2.4 diff -u -r1.11.2.3 -r1.11.2.4 --- junitreport.html 2 Jun 2004 12:33:21 -0000 1.11.2.3 +++ junitreport.html 25 Jun 2004 13:50:16 -0000 1.11.2.4 @@ -15,21 +15,25 @@ Library Dependencies</a> for more information.</p> <h3>Requirements</h3> -<p>The task needs <a href="http://xml.apache.org/xalan-j/">Xalan -2.x</a>; although <a -href="http://xml.apache.org/dist/xalan-j/old/xalan-j_1_2_2.zip">Xalan -1.2.2</a> does work, but as Xalan1 is not supported, we do not -recommend this. While JDK 1.4.x contains a version of Xalan-J 2, JDK -1.5 and later have <a -href="http://java.sun.com/j2se/1.5.0/compatibility.html#4959783">moved -to XSLTC</a>. Since this task uses Xalan's redirect extensions for -its internal stylesheet, Ant doesn't support XSLTC yet. This means -that you have to install Xalan-J 2 in order to use this task with JDK -1.5.</p> -<p> -If you do you use Xalan 1.2.2 you will need a compatible (older) version of Xerces. -as well as BSF(bsf.jar). Again, using Xalan 2 is simpler and supported. -</i></p> + +<p>The task needs Apache <a +href="http://xml.apache.org/xalan-j/">Xalan 2.x or Xalan XSLTC</a> +(JDK 1.4 contains a version of Xalan-J 2.x while JDK 1.5 ships with a +version of XSLTC). Versions prior to Ant 1.6.2 worked with Apache <a +href="http://archive.apache.org/dist/xml/xalan-j/">Xalan +1.2.2</a>, but as Xalan1 is no longer supported, we do not recommend +this. With Ant 1.6.2 we had to decide between supporting Xalan-J 1 +and XSLTC, since there was no way to support both at the same +time.</p> + +<p>If you want to use Xalan 1.2.2, the noframes report is still +supposed to work. If you want the frames support, copy the file +junit-frames-xalan1.xsl from the Ant distribution's etc directory to a +new directory, change its name to junit-frames.xsl and use the task's +styledir attribute to point to it. You will also need a compatible +(older) version of Xerces. as well as BSF(bsf.jar). Again, using +Xalan 2 is simpler and supported.</p> + <h3>Parameters</h3> <table border="1" cellpadding="2" cellspacing="0"> <tr> No revision No revision 1.16.2.5 +1 -1 ant/src/etc/junit-frames.xsl Index: junit-frames.xsl =================================================================== RCS file: /home/cvs/ant/src/etc/junit-frames.xsl,v retrieving revision 1.16.2.4 retrieving revision 1.16.2.5 diff -u -r1.16.2.4 -r1.16.2.5 --- junit-frames.xsl 8 Jun 2004 13:54:53 -0000 1.16.2.4 +++ junit-frames.xsl 25 Jun 2004 13:50:16 -0000 1.16.2.5 @@ -1,6 +1,6 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:lxslt="http://xml.apache.org/xslt" - xmlns:redirect="org.apache.xalan.lib.Redirect" + xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils" extension-element-prefixes="redirect"> <xsl:output method="html" indent="yes" encoding="US-ASCII"/> No revision Index: junit-frames.xsl =================================================================== RCS file: /home/cvs/ant/src/etc/junit-frames.xsl,v retrieving revision 1.16.2.4 retrieving revision 1.16.2.5 diff -u -r1.16.2.4 -r1.16.2.5 --- junit-frames.xsl 8 Jun 2004 13:54:53 -0000 1.16.2.4 +++ junit-frames.xsl 25 Jun 2004 13:50:16 -0000 1.16.2.5 @@ -1,6 +1,6 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:lxslt="http://xml.apache.org/xslt" - xmlns:redirect="org.apache.xalan.lib.Redirect" + xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils" extension-element-prefixes="redirect"> <xsl:output method="html" indent="yes" encoding="US-ASCII"/> No revision Index: junit-frames.xsl =================================================================== RCS file: /home/cvs/ant/src/etc/junit-frames.xsl,v retrieving revision 1.16.2.4 retrieving revision 1.16.2.5 diff -u -r1.16.2.4 -r1.16.2.5 --- junit-frames.xsl 8 Jun 2004 13:54:53 -0000 1.16.2.4 +++ junit-frames.xsl 25 Jun 2004 13:50:16 -0000 1.16.2.5 @@ -1,6 +1,6 @@ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:lxslt="http://xml.apache.org/xslt" - xmlns:redirect="org.apache.xalan.lib.Redirect" + xmlns:redirect="http://xml.apache.org/xalan/redirect" xmlns:stringutils="xalan://org.apache.tools.ant.util.StringUtils" extension-element-prefixes="redirect"> <xsl:output method="html" indent="yes" encoding="US-ASCII"/> 1.1.2.1 +0 -0 ant/src/etc/junit-frames-xalan1.xsl Index: junit-frames-xalan1.xsl =================================================================== RCS file: /home/cvs/ant/src/etc/junit-frames-xalan1.xsl,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -u -r1.1 -r1.1.2.1 No revision No revision 1.10.2.4 +27 -2 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java Index: Xalan1Executor.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan1Executor.java,v retrieving revision 1.10.2.3 retrieving revision 1.10.2.4 diff -u -r1.10.2.3 -r1.10.2.4 --- Xalan1Executor.java 9 Feb 2004 22:12:34 -0000 1.10.2.3 +++ Xalan1Executor.java 25 Jun 2004 13:50:16 -0000 1.10.2.4 @@ -30,10 +30,35 @@ * @ant.task ignore="true" */ public class Xalan1Executor extends XalanExecutor { + + private static final String xsltP = "org.apache.xalan.xslt.XSLTProcessor"; + + private XSLTProcessor processor = XSLTProcessorFactory.getProcessor(); + + protected String getImplementation() { + return processor.getClass().getName(); + } + + protected String getProcVersion(String classNameImpl) + throws BuildException { + try { + // xalan 1 + if (classNameImpl.equals(xsltP)){ + return getXalanVersion(xsltP + "Version"); + } + throw new BuildException("Could not find a valid processor version" + + " implementation from " + + classNameImpl); + } catch (ClassNotFoundException e){ + throw new BuildException("Could not find processor version " + + "implementation", e); + } + } + void execute() throws Exception { - XSLTProcessor processor = XSLTProcessorFactory.getProcessor(); // need to quote otherwise it breaks because of "extra illegal tokens" - processor.setStylesheetParam("output.dir", "'" + caller.toDir.getAbsolutePath() + "'"); + processor.setStylesheetParam("output.dir", "'" + + caller.toDir.getAbsolutePath() + "'"); XSLTInputSource xml_src = new XSLTInputSource(caller.document); String system_id = caller.getStylesheetSystemId(); XSLTInputSource xsl_src = new XSLTInputSource(system_id); 1.7.2.4 +41 -1 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java Index: Xalan2Executor.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/Xalan2Executor.java,v retrieving revision 1.7.2.3 retrieving revision 1.7.2.4 diff -u -r1.7.2.3 -r1.7.2.4 --- Xalan2Executor.java 9 Feb 2004 22:12:34 -0000 1.7.2.3 +++ Xalan2Executor.java 25 Jun 2004 13:50:16 -0000 1.7.2.4 @@ -25,6 +25,8 @@ import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; +import org.apache.tools.ant.BuildException; + /** * Xalan executor via JAXP. Nothing special must exists in the classpath * besides of course, a parser, jaxp and xalan. @@ -32,8 +34,46 @@ * @ant.task ignore="true" */ public class Xalan2Executor extends XalanExecutor { + + private static final String aPack = "org.apache.xalan."; + private static final String sPack = "com.sun.org.apache.xalan."; + + private TransformerFactory tfactory = TransformerFactory.newInstance(); + + protected String getImplementation() throws BuildException { + return tfactory.getClass().getName(); + } + + protected String getProcVersion(String classNameImpl) + throws BuildException { + try { + // xalan 2 + if (classNameImpl.equals(aPack + "processor.TransformerFactoryImpl") + || + classNameImpl.equals(aPack + "xslt.XSLTProcessorFactory")) { + return getXalanVersion(aPack + "processor.XSLProcessorVersion"); + } + // xalan xsltc + if (classNameImpl.equals(aPack + + "xsltc.trax.TransformerFactoryImpl")){ + return getXSLTCVersion(aPack +"xsltc.ProcessorVersion"); + } + // jdk 1.5 xsltc + if (classNameImpl + .equals(sPack + "internal.xsltc.trax.TransformerFactoryImpl")){ + return getXSLTCVersion(sPack + + "internal.xsltc.ProcessorVersion"); + } + throw new BuildException("Could not find a valid processor version" + + " implementation from " + + classNameImpl); + } catch (ClassNotFoundException e){ + throw new BuildException("Could not find processor version " + + "implementation", e); + } + } + void execute() throws Exception { - TransformerFactory tfactory = TransformerFactory.newInstance(); String system_id = caller.getStylesheetSystemId(); Source xsl_src = new StreamSource(system_id); Transformer tformer = tfactory.newTransformer(xsl_src); 1.11.2.5 +59 -36 ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java Index: XalanExecutor.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/optional/junit/XalanExecutor.java,v retrieving revision 1.11.2.4 retrieving revision 1.11.2.5 diff -u -r1.11.2.4 -r1.11.2.5 --- XalanExecutor.java 2 Jun 2004 12:33:21 -0000 1.11.2.4 +++ XalanExecutor.java 25 Jun 2004 13:50:16 -0000 1.11.2.5 @@ -33,9 +33,12 @@ * Command class that encapsulate specific behavior for each * Xalan version. The right executor will be instantiated at * runtime via class lookup. For instance, it will check first - * for Xalan2, then for Xalan1. + * for Xalan2/XSLTC, then for Xalan1. */ abstract class XalanExecutor { + private static final String pack = + "org.apache.tools.ant.taskdefs.optional.junit."; + /** the transformer caller */ protected AggregateTransformer caller; @@ -45,7 +48,7 @@ } /** get the appropriate stream based on the format (frames/noframes) */ - protected OutputStream getOutputStream() throws IOException { + protected final OutputStream getOutputStream() throws IOException { if (AggregateTransformer.FRAMES.equals(caller.format)) { // dummy output for the framed report // it's all done by extension... @@ -66,53 +69,73 @@ * @throws BuildException thrown if it could not find a valid xalan * executor. */ - static XalanExecutor newInstance(AggregateTransformer caller) throws BuildException { - Class procVersion = null; + static XalanExecutor newInstance(AggregateTransformer caller) + throws BuildException { XalanExecutor executor = null; try { - procVersion = Class.forName("org.apache.xalan.processor.XSLProcessorVersion"); - executor = (XalanExecutor) Class.forName( - "org.apache.tools.ant.taskdefs.optional.junit.Xalan2Executor").newInstance(); - } catch (Exception xalan2missing) { - StringWriter swr = new StringWriter(); - xalan2missing.printStackTrace(new PrintWriter(swr)); - caller.task.log("Didn't find Xalan2.", Project.MSG_DEBUG); - caller.task.log(swr.toString(), Project.MSG_DEBUG); + Class clazz = Class.forName(pack + "Xalan2Executor"); + executor = (XalanExecutor)clazz.newInstance(); + } catch (Exception xsltcApacheMissing){ + caller.task.log(xsltcApacheMissing.toString()); try { - procVersion = Class.forName("org.apache.xalan.xslt.XSLProcessorVersion"); - executor = (XalanExecutor) Class.forName( - "org.apache.tools.ant.taskdefs.optional.junit.Xalan1Executor").newInstance(); - } catch (Exception xalan1missing) { - swr = new StringWriter(); - xalan1missing.printStackTrace(new PrintWriter(swr)); - caller.task.log("Didn't find Xalan1.", Project.MSG_DEBUG); - caller.task.log(swr.toString(), Project.MSG_DEBUG); - String msg = "Could not find xalan2 nor xalan1 " - + "in the classpath. Check http://xml.apache.org/xalan-j/"; - if (!JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_1) - && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_2) - && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_3) - && !JavaEnvUtils.isJavaVersion(JavaEnvUtils.JAVA_1_4)) { - msg += "\r\nStarting with JDK 1.5, the built-in processor " - + "of the JDK is no longer Xalan\r\nbut XSLTC which is " - + "not (yet) supported by the junitreport task."; - } - throw new BuildException(msg); + Class clazz = Class.forName(pack + "Xalan1Executor"); + executor = (XalanExecutor) clazz.newInstance(); + } catch (Exception xalan1Missing){ + caller.task.log(xalan1Missing.toString()); + throw new BuildException("Could not find xstlc nor xalan2 nor " + + "xalan1 in the classpath. Check " + + "http://xml.apache.org/xalan-j"); } } - String version = getXalanVersion(procVersion); - caller.task.log("Using Xalan version: " + version); + String classNameImpl = executor.getImplementation(); + String version = executor.getProcVersion(classNameImpl); + caller.task.log("Using " + version, Project.MSG_VERBOSE); executor.setCaller(caller); return executor; } + /** + * This methods should return the classname implementation of the + * underlying xslt processor + * @return the classname of the implementation, for example: + * org.apache.xalan.processor.TransformerFactoryImpl + * @see #getProcVersion(String) + */ + protected abstract String getImplementation(); + + /** + * Try to discover the xslt processor version based on the + * className. There is nothing carved in stone and it can change + * anytime, so this is just for the sake of giving additional + * information if we can find it. + * @param classNameImpl the classname of the underlying xslt processor + * @return a string representing the implementation version. + * @throws BuildException + */ + protected abstract String getProcVersion(String classNameImpl) + throws BuildException; + + /** a bit simplistic but xsltc data are conveniently private non final */ + protected final String getXSLTCVersion(String procVersionClassName) + throws ClassNotFoundException { + // there's a convenient xsltc class version but data are + // private so use package information + Class procVersion = Class.forName(procVersionClassName); + Package pkg = procVersion.getPackage(); + return pkg.getName() + " " + pkg.getImplementationTitle() + + " " + pkg.getImplementationVersion(); + } + /** pretty useful data (Xalan version information) to display. */ - private static String getXalanVersion(Class procVersion) { + protected final String getXalanVersion(String procVersionClassName) + throws ClassNotFoundException { + Class procVersion = Class.forName(procVersionClassName); + String pkg = procVersion.getPackage().getName(); try { Field f = procVersion.getField("S_VERSION"); - return f.get(null).toString(); + return pkg + " " + f.get(null).toString(); } catch (Exception e) { - return "?"; + return pkg + " ?.?"; } } } No revision No revision 1.38.2.14 +2 -3 ant/xdocs/faq.xml Index: faq.xml =================================================================== RCS file: /home/cvs/ant/xdocs/faq.xml,v retrieving revision 1.38.2.13 retrieving revision 1.38.2.14 diff -u -r1.38.2.13 -r1.38.2.14 --- faq.xml 2 Jun 2004 12:33:21 -0000 1.38.2.13 +++ faq.xml 25 Jun 2004 13:50:16 -0000 1.38.2.14 @@ -1486,9 +1486,8 @@ href="http://xml.apache.org/xalan-j/">Xalan-J 2</a> in order to use this task with JDK 1.5.</p> - <p>If you want to follow progress on this, <a - href="http://issues.apache.org/bugzilla/show_bug.cgi?id=27541">here</a> - is the relevant bug report.</p> + <p>Starting with Ant 1.6.2 <code><junitreport></code> + will support JDK 1.5.</p> </answer> </faq>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]