Browse Source

Merge from ANT_145_BRANCH up to Beta 2

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269587 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
f66cab0ea7
45 changed files with 1314 additions and 297 deletions
  1. +112
    -100
      src/etc/junit-frames.xsl
  2. +20
    -0
      src/etc/testcases/taskdefs/optional/xalan-redirect-in.xsl
  3. +4
    -0
      src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xml
  4. +10
    -0
      src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xsl
  5. +7
    -0
      src/etc/testcases/taskdefs/optional/xsltliaison-in.xml
  6. +3
    -0
      src/etc/testcases/taskdefs/optional/xsltliaison-in.xsl
  7. +2
    -0
      src/etc/testcases/taskdefs/optional/xsltliaison-include.xml
  8. +3
    -0
      src/etc/testcases/taskdefs/optional/xsltliaison-include.xsl
  9. +37
    -0
      src/etc/testcases/types/filterset.xml
  10. +2
    -0
      src/etc/testcases/types/filterseta.txt
  11. +5
    -0
      src/etc/testcases/types/filtersetb.txt
  12. +7
    -0
      src/etc/testcases/types/filtersetc.txt
  13. +2
    -0
      src/etc/testcases/types/gold/filterset1.txt
  14. +5
    -0
      src/etc/testcases/types/gold/filterset2.txt
  15. +7
    -0
      src/etc/testcases/types/gold/filterset3.txt
  16. +9
    -8
      src/main/org/apache/tools/ant/Main.java
  17. +14
    -12
      src/main/org/apache/tools/ant/Project.java
  18. +3
    -2
      src/main/org/apache/tools/ant/listener/Log4jListener.java
  19. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/Copy.java
  20. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/DependSet.java
  21. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
  22. +10
    -1
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  23. +15
    -0
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  24. +3
    -2
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  25. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/Move.java
  26. +36
    -4
      src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java
  27. +19
    -19
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
  28. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
  29. +15
    -1
      src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
  30. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/defaults.properties
  31. +67
    -19
      src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
  32. +48
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java
  33. +22
    -17
      src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java
  34. +96
    -47
      src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
  35. +14
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
  36. +3
    -4
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java
  37. +35
    -13
      src/main/org/apache/tools/ant/types/FilterSet.java
  38. +127
    -0
      src/main/org/apache/tools/ant/types/FilterSetCollection.java
  39. +14
    -14
      src/main/org/apache/tools/ant/util/FileUtils.java
  40. +128
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java
  41. +87
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
  42. +88
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java
  43. +72
    -0
      src/testcases/org/apache/tools/ant/taskdefs/optional/XslpLiaisonTest.java
  44. +144
    -0
      src/testcases/org/apache/tools/ant/types/FilterSetTest.java
  45. +2
    -1
      src/testcases/org/apache/tools/ant/util/FileUtilsTest.java

+ 112
- 100
src/etc/junit-frames.xsl View File

@@ -6,7 +6,7 @@


<!-- ====================================================================== <!-- ======================================================================


Stylesheet to transform an XML file generated by the Ant MAudit task into
Stylesheet to transform an XML file generated by the Ant JUnit task into
a set of JavaDoc-like HTML page to make pages more convenient to be browsed. a set of JavaDoc-like HTML page to make pages more convenient to be browsed.
It use the Xalan redirect extension to write to multiple output files. It use the Xalan redirect extension to write to multiple output files.
@@ -14,8 +14,8 @@
Note: HTML output can be made much more clean by removing non css attributes Note: HTML output can be made much more clean by removing non css attributes


====================================================================== --> ====================================================================== -->
<xsl:output method="html" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator="," />
<xsl:output method="html" indent="yes"/>
<xsl:decimal-format decimal-separator="." grouping-separator=","/>


<!-- <!--
Xalan redirect extension writes relative file based on the parent directory Xalan redirect extension writes relative file based on the parent directory
@@ -27,7 +27,7 @@
This has to be invoked as follows from the command line: This has to be invoked as follows from the command line:
java -classpath bsf.jar;xalan.jar;xerces.jar org.apache.xalan.xslt.Process -IN testsuites.xml -XSL maudit.xsl -PARAM output.dir './report'
java -classpath bsf.jar;xalan.jar;xerces.jar org.apache.xalan.xslt.Process -IN testsuites.xml -XSL junit-frames.xsl -PARAM output.dir './report'
--> -->
<xsl:param name="output.dir" select="'.'"/> <xsl:param name="output.dir" select="'.'"/>


@@ -98,61 +98,72 @@
</xsl:template> </xsl:template>


<xsl:template name="index.html"> <xsl:template name="index.html">
<HTML>
<HEAD><TITLE>Unit Test Results.</TITLE></HEAD>
<FRAMESET cols="20%,80%">
<FRAMESET rows="30%,70%">
<FRAME src="overview-frame.html" name="packageListFrame"/>
<FRAME src="allclasses-frame.html" name="classListFrame"/>
</FRAMESET>
<FRAME src="overview-summary.html" name="classFrame"/>
</FRAMESET>
<html>
<head>
<title>Unit Test Results.</title>
</head>
<frameset cols="20%,80%">
<frameset rows="30%,70%">
<frame src="overview-frame.html" name="packageListFrame"/>
<frame src="allclasses-frame.html" name="classListFrame"/>
</frameset>
<frame src="overview-summary.html" name="classFrame"/>
</frameset>
<noframes> <noframes>
<H2>Frame Alert</H2>
<P>
<h2>Frame Alert</h2>
<p>
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
</P>
</p>
</noframes> </noframes>
</HTML>
</html>
</xsl:template> </xsl:template>




<!-- this is the stylesheet css to use for nearly everything --> <!-- this is the stylesheet css to use for nearly everything -->
<xsl:template name="stylesheet.css"> <xsl:template name="stylesheet.css">
BODY {
body {
font:normal 68% verdana,arial,helvetica; font:normal 68% verdana,arial,helvetica;
color:#000000; color:#000000;
} }
TD {
FONT-SIZE: 68%
td {
font-size: 68%
} }
P {
p {
line-height:1.5em; line-height:1.5em;
margin-top:0.5em; margin-bottom:1.0em; margin-top:0.5em; margin-bottom:1.0em;
} }
H1 {
MARGIN: 0px 0px 5px; FONT: 165% verdana,arial,helvetica
h1 {
margin: 0px 0px 5px;
font: 165% verdana,arial,helvetica
} }
H2 {
MARGIN-TOP: 1em; MARGIN-BOTTOM: 0.5em; FONT: bold 125% verdana,arial,helvetica
h2 {
margin-top: 1em;
margin-bottom: 0.5em;
font: bold 125% verdana,arial,helvetica
} }
H3 {
MARGIN-BOTTOM: 0.5em; FONT: bold 115% verdana,arial,helvetica
h3 {
margin-bottom: 0.5em;
font: bold 115% verdana,arial,helvetica
} }
H4 {
MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
h4 {
margin-bottom: 0.5em;
font: bold 100% verdana,arial,helvetica
} }
H5 {
MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
h5 {
margin-bottom: 0.5em;
font: bold 100% verdana,arial,helvetica
} }
H6 {
MARGIN-BOTTOM: 0.5em; FONT: bold 100% verdana,arial,helvetica
h6 {
margin-bottom: 0.5em;
font: bold 100% verdana,arial,helvetica
} }
.Error { .Error {
font-weight:bold; color:red;
font-weight:bold;
color:red;
} }
.Failure { .Failure {
font-weight:bold; color:purple;
font-weight:bold;
color:purple;
} }


</xsl:template> </xsl:template>
@@ -165,15 +176,15 @@ H6 {
====================================================================== --> ====================================================================== -->
<xsl:template match="testsuite" mode="class.details"> <xsl:template match="testsuite" mode="class.details">
<xsl:variable name="package.name" select="@package"/> <xsl:variable name="package.name" select="@package"/>
<HTML>
<HEAD>
<html>
<head>
<xsl:call-template name="create.stylesheet.link"> <xsl:call-template name="create.stylesheet.link">
<xsl:with-param name="package.name" select="$package.name"/> <xsl:with-param name="package.name" select="$package.name"/>
</xsl:call-template> </xsl:call-template>
</HEAD>
<BODY>
</head>
<body>
<xsl:call-template name="pageHeader"/> <xsl:call-template name="pageHeader"/>
<H3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></H3>
<h3>Class <xsl:if test="not($package.name = '')"><xsl:value-of select="$package.name"/>.</xsl:if><xsl:value-of select="@name"/></h3>


<table border="0" cellpadding="5" cellspacing="2" width="95%"> <table border="0" cellpadding="5" cellspacing="2" width="95%">
@@ -181,7 +192,7 @@ H6 {
<xsl:apply-templates select="." mode="print.test"/> <xsl:apply-templates select="." mode="print.test"/>
</table> </table>
<H2>Tests</H2>
<h2>Tests</h2>
<p> <p>
<table border="0" cellpadding="5" cellspacing="2" width="95%"> <table border="0" cellpadding="5" cellspacing="2" width="95%">
<xsl:call-template name="testcase.test.header"/> <xsl:call-template name="testcase.test.header"/>
@@ -189,8 +200,8 @@ H6 {
</table> </table>
</p> </p>
</BODY>
</HTML>
</body>
</html>
</xsl:template> </xsl:template>




@@ -202,24 +213,24 @@ H6 {
<!-- list of classes in a package --> <!-- list of classes in a package -->
<xsl:template name="classes.list"> <xsl:template name="classes.list">
<xsl:param name="name"/> <xsl:param name="name"/>
<HTML>
<HEAD>
<html>
<head>
<xsl:call-template name="create.stylesheet.link"> <xsl:call-template name="create.stylesheet.link">
<xsl:with-param name="package.name" select="$name"/> <xsl:with-param name="package.name" select="$name"/>
</xsl:call-template> </xsl:call-template>
</HEAD>
<BODY>
</head>
<body>
<table width="100%"> <table width="100%">
<tr> <tr>
<td nowrap="nowrap"> <td nowrap="nowrap">
<H2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></H2>
<h2><a href="package-summary.html" target="classFrame"><xsl:value-of select="$name"/></a></h2>
</td> </td>
</tr> </tr>
</table> </table>
<H2>Classes</H2>
<h2>Classes</h2>
<p> <p>
<TABLE WIDTH="100%">
<table width="100%">
<xsl:for-each select="/testsuites/testsuite[./@package = $name]"> <xsl:for-each select="/testsuites/testsuite[./@package = $name]">
<xsl:sort select="@name"/> <xsl:sort select="@name"/>
<tr> <tr>
@@ -228,10 +239,10 @@ H6 {
</td> </td>
</tr> </tr>
</xsl:for-each> </xsl:for-each>
</TABLE>
</table>
</p> </p>
</BODY>
</HTML>
</body>
</html>
</xsl:template> </xsl:template>




@@ -260,8 +271,8 @@ H6 {
</xsl:template> </xsl:template>


<xsl:template match="testsuite" mode="all.classes"> <xsl:template match="testsuite" mode="all.classes">
<!-- (ancestor::package)[last()] is buggy in MSXML3, fixed in SP1 ? -->
<xsl:variable name="package.name" select="@package"/>
<!-- (ancestor::package)[last()] is buggy in MSXML3, fixed in SP1? -->
<xsl:variable name="package.name" select="@package"/>
<tr> <tr>
<td nowrap="nowrap"> <td nowrap="nowrap">
<a target="classFrame"> <a target="classFrame">
@@ -295,7 +306,7 @@ H6 {
<p> <p>
<table width="100%"> <table width="100%">
<xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages"> <xsl:apply-templates select="testsuite[not(./@package = preceding-sibling::testsuite/@package)]" mode="all.packages">
<xsl:sort select="@name"/>
<xsl:sort select="@package"/>
</xsl:apply-templates> </xsl:apply-templates>
</table> </table>
</p> </p>
@@ -321,7 +332,7 @@ H6 {
<xsl:with-param name="package.name"/> <xsl:with-param name="package.name"/>
</xsl:call-template> </xsl:call-template>
</head> </head>
<body onload="open('allclasses-frame.html','classListFrame')">
<body>
<xsl:call-template name="pageHeader"/> <xsl:call-template name="pageHeader"/>
<h2>Summary</h2> <h2>Summary</h2>
<xsl:variable name="testCount" select="sum(testsuite/@tests)"/> <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
@@ -331,20 +342,20 @@ H6 {
<xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/> <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
<table border="0" cellpadding="5" cellspacing="2" width="95%"> <table border="0" cellpadding="5" cellspacing="2" width="95%">
<tr bgcolor="#A6CAF0" valign="top"> <tr bgcolor="#A6CAF0" valign="top">
<td><b>Tests</b></td>
<td><b>Failures</b></td>
<td><b>Errors</b></td>
<td><b>Success rate</b></td>
<td><b>Time</b></td>
<td><strong>Tests</strong></td>
<td><strong>Failures</strong></td>
<td><strong>Errors</strong></td>
<td><strong>Success rate</strong></td>
<td><strong>Time</strong></td>
</tr> </tr>
<tr bgcolor="#EEEEE" valign="top"> <tr bgcolor="#EEEEE" valign="top">
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
<xsl:when test="$errorCount &gt; 0">Error</xsl:when>
<xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="$errorCount &gt; 0">Error</xsl:when>
<xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
<xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td><xsl:value-of select="$testCount"/></td> <td><xsl:value-of select="$testCount"/></td>
<td><xsl:value-of select="$failureCount"/></td> <td><xsl:value-of select="$failureCount"/></td>
<td><xsl:value-of select="$errorCount"/></td> <td><xsl:value-of select="$errorCount"/></td>
@@ -364,7 +375,7 @@ H6 {
<table border="0" width="95%"> <table border="0" width="95%">
<tr> <tr>
<td style="text-align: justify;"> <td style="text-align: justify;">
Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated.
Note: <em>failures</em> are anticipated and checked for with assertions while <em>errors</em> are unanticipated.
</td> </td>
</tr> </tr>
</table> </table>
@@ -377,13 +388,14 @@ H6 {
<!-- get the node set containing all testsuites that have the same package --> <!-- get the node set containing all testsuites that have the same package -->
<xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/> <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = current()/@package]"/>
<tr bgcolor="#EEEEE" valign="top"> <tr bgcolor="#EEEEE" valign="top">
<!-- display a failure if there is any failure/error in the package -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="sum($insamepackage/@errors) + sum($insamepackage/@failures) &gt; 0">Failure</xsl:when>
<xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<!-- display a failure if there is any failure/error in the package -->
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="sum($insamepackage/@errors) &gt; 0">Error</xsl:when>
<xsl:when test="sum($insamepackage/@failures) &gt; 0">Failure</xsl:when>
<xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
<td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td> <td><a href="{translate(@package,'.','/')}/package-summary.html"><xsl:value-of select="@package"/></a></td>
<td><xsl:value-of select="sum($insamepackage/@tests)"/></td> <td><xsl:value-of select="sum($insamepackage/@tests)"/></td>
<td><xsl:value-of select="sum($insamepackage/@errors)"/></td> <td><xsl:value-of select="sum($insamepackage/@errors)"/></td>
@@ -403,13 +415,13 @@ H6 {


<xsl:template name="package.summary"> <xsl:template name="package.summary">
<xsl:param name="name"/> <xsl:param name="name"/>
<HTML>
<HEAD>
<html>
<head>
<xsl:call-template name="create.stylesheet.link"> <xsl:call-template name="create.stylesheet.link">
<xsl:with-param name="package.name" select="$name"/> <xsl:with-param name="package.name" select="$name"/>
</xsl:call-template> </xsl:call-template>
</HEAD>
<BODY>
</head>
<body>
<xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute> <xsl:attribute name="onload">open('package-frame.html','classListFrame')</xsl:attribute>
<xsl:call-template name="pageHeader"/> <xsl:call-template name="pageHeader"/>
<h3>Package <xsl:value-of select="$name"/></h3> <h3>Package <xsl:value-of select="$name"/></h3>
@@ -421,7 +433,7 @@ H6 {
<xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/> <xsl:variable name="insamepackage" select="/testsuites/testsuite[./@package = $name]"/>
<xsl:if test="count($insamepackage) &gt; 0"> <xsl:if test="count($insamepackage) &gt; 0">
<H2>Classes</H2>
<h2>Classes</h2>
<p> <p>
<table border="0" cellpadding="5" cellspacing="2" width="95%"> <table border="0" cellpadding="5" cellspacing="2" width="95%">
<xsl:call-template name="testsuite.test.header"/> <xsl:call-template name="testsuite.test.header"/>
@@ -431,8 +443,8 @@ H6 {
</table> </table>
</p> </p>
</xsl:if> </xsl:if>
</BODY>
</HTML>
</body>
</html>
</xsl:template> </xsl:template>




@@ -457,7 +469,7 @@ H6 {
<!-- create the link to the stylesheet based on the package name --> <!-- create the link to the stylesheet based on the package name -->
<xsl:template name="create.stylesheet.link"> <xsl:template name="create.stylesheet.link">
<xsl:param name="package.name"/> <xsl:param name="package.name"/>
<LINK REL ="stylesheet" TYPE="text/css" TITLE="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></LINK>
<link rel="stylesheet" type="text/css" title="Style"><xsl:attribute name="href"><xsl:if test="not($package.name = 'unnamed package')"><xsl:call-template name="path"><xsl:with-param name="path" select="$package.name"/></xsl:call-template></xsl:if>stylesheet.css</xsl:attribute></link>
</xsl:template> </xsl:template>




@@ -476,32 +488,32 @@ H6 {
<!-- class header --> <!-- class header -->
<xsl:template name="testsuite.test.header"> <xsl:template name="testsuite.test.header">
<tr bgcolor="#A6CAF0" valign="top"> <tr bgcolor="#A6CAF0" valign="top">
<td width="80%"><b>Name</b></td>
<td><b>Tests</b></td>
<td><b>Errors</b></td>
<td><b>Failures</b></td>
<td nowrap="nowrap"><b>Time(s)</b></td>
<td width="80%"><strong>Name</strong></td>
<td><strong>Tests</strong></td>
<td><strong>Errors</strong></td>
<td><strong>Failures</strong></td>
<td nowrap="nowrap"><strong>Time(s)</strong></td>
</tr> </tr>
</xsl:template> </xsl:template>


<!-- method header --> <!-- method header -->
<xsl:template name="testcase.test.header"> <xsl:template name="testcase.test.header">
<tr bgcolor="#A6CAF0" valign="top"> <tr bgcolor="#A6CAF0" valign="top">
<td><b>Name</b></td>
<td><b>Status</b></td>
<td width="80%"><b>Type</b></td>
<td nowrap="nowrap"><b>Time(s)</b></td>
<td><strong>Name</strong></td>
<td><strong>Status</strong></td>
<td width="80%"><strong>Type</strong></td>
<td nowrap="nowrap"><strong>Time(s)</strong></td>
</tr> </tr>
</xsl:template> </xsl:template>




<!-- class information --> <!-- class information -->
<xsl:template match="testsuite" mode="print.test"> <xsl:template match="testsuite" mode="print.test">
<tr bgcolor="#EEEEE" valign="top">
<tr bgcolor="#EEEEE" valign="top">
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:choose> <xsl:choose>
<xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
<xsl:when test="@errors[.&gt; 0]">Error</xsl:when> <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
<xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
<xsl:otherwise>Pass</xsl:otherwise> <xsl:otherwise>Pass</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
@@ -520,7 +532,8 @@ H6 {
<tr bgcolor="#EEEEE" valign="top"> <tr bgcolor="#EEEEE" valign="top">
<xsl:attribute name="class"> <xsl:attribute name="class">
<xsl:choose> <xsl:choose>
<xsl:when test="failure | error">Error</xsl:when>
<xsl:when test="error">Error</xsl:when>
<xsl:when test="failure">Failure</xsl:when>
<xsl:otherwise>TableRowColor</xsl:otherwise> <xsl:otherwise>TableRowColor</xsl:otherwise>
</xsl:choose> </xsl:choose>
</xsl:attribute> </xsl:attribute>
@@ -558,7 +571,7 @@ H6 {
<xsl:call-template name="display-failures"/> <xsl:call-template name="display-failures"/>
</xsl:template> </xsl:template>


<!-- Style for the error and failure in the tescase template -->
<!-- Style for the error and failure in the testcase template -->
<xsl:template name="display-failures"> <xsl:template name="display-failures">
<xsl:choose> <xsl:choose>
<xsl:when test="not(@message)">N/A</xsl:when> <xsl:when test="not(@message)">N/A</xsl:when>
@@ -573,7 +586,7 @@ H6 {
<xsl:with-param name="word" select="."/> <xsl:with-param name="word" select="."/>
</xsl:call-template> </xsl:call-template>
</code> </code>
<!-- the later is better but might be problematic for non-21" monitors... -->
<!-- the latter is better but might be problematic for non-21" monitors... -->
<!--pre><xsl:value-of select="."/></pre--> <!--pre><xsl:value-of select="."/></pre-->
</xsl:template> </xsl:template>


@@ -606,6 +619,5 @@ H6 {
<xsl:param name="value"/> <xsl:param name="value"/>
<xsl:value-of select="format-number($value,'0.00%')"/> <xsl:value-of select="format-number($value,'0.00%')"/>
</xsl:template> </xsl:template>

</xsl:stylesheet> </xsl:stylesheet>

+ 20
- 0
src/etc/testcases/taskdefs/optional/xalan-redirect-in.xsl View File

@@ -0,0 +1,20 @@
<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.xslt.extensions.Redirect"
extension-element-prefixes="redirect">
<!--
This is a test to ensure that systemid is set correctly
for a xsl...the behavior might be dependent on Xalan1
and Xalan2...this will be a problem to erase the files :(
Can take as a systemid the base for the xsl document or
the base or the JVM working dir just like: new File("xalan-redirect-out.tmp")
-->
<xsl:param name="xalan-version" select="'x'"/>

<xsl:template match="/">
<redirect:write file="./xalan{$xalan-version}-redirect-out.tmp">
<test>This should be written to the file</test>
</redirect:write>
</xsl:template>

</xsl:stylesheet>

+ 4
- 0
src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xml View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<message>éàèïù</message>
</root>

+ 10
- 0
src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xsl View File

@@ -0,0 +1,10 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:template match="/">
<root>
<xsl:for-each select="/root/message">
<message><xsl:value-of select="."/></message>
</xsl:for-each>
</root>
</xsl:template>
</xsl:stylesheet>

+ 7
- 0
src/etc/testcases/taskdefs/optional/xsltliaison-in.xml View File

@@ -0,0 +1,7 @@
<?xml version="1.0"?>
<!DOCTYPE project [
<!ENTITY include SYSTEM "xsltliaison-include.xml">
]>
<project>
&include;
</project>

+ 3
- 0
src/etc/testcases/taskdefs/optional/xsltliaison-in.xsl View File

@@ -0,0 +1,3 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:include href="xsltliaison-include.xsl"/>
</xsl:stylesheet>

+ 2
- 0
src/etc/testcases/taskdefs/optional/xsltliaison-include.xml View File

@@ -0,0 +1,2 @@
<!-- to be included by xsltliaison-include.xsl -->
<task/>

+ 3
- 0
src/etc/testcases/taskdefs/optional/xsltliaison-include.xsl View File

@@ -0,0 +1,3 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- to be included by xsltliaison-in.xsl -->
</xsl:stylesheet>

+ 37
- 0
src/etc/testcases/types/filterset.xml View File

@@ -0,0 +1,37 @@
<project name="test" default="new" basedir=".">
<filterset id="testset.one">
<filter token="aaaa" value="1111"/>
<filter token="bbbb" value="2222"/>
</filterset>
<filterset id="testset.two" beginToken="%" endToken="^">
<filter token="cccc" value="3333"/>
<filter token="dddd" value="4444"/>
</filterset>
<target name="test1">
<delete file="dest1.txt"/>
<copy file="filterseta.txt" tofile="dest1.txt">
<filterset refid="testset.one"/>
</copy>
<fixcrlf eol="lf" srcdir="." includes="dest1.txt"/>
</target>

<target name="test2">
<delete file="dest2.txt"/>
<copy file="filtersetb.txt" tofile="dest2.txt">
<filterset refid="testset.two"/>
</copy>
<fixcrlf eol="lf" srcdir="." includes="dest2.txt"/>
</target>

<target name="test3">
<delete file="dest3.txt"/>
<copy file="filtersetc.txt" tofile="dest3.txt">
<filterset refid="testset.one"/>
<filterset refid="testset.two"/>
</copy>
<fixcrlf eol="lf" srcdir="." includes="dest3.txt"/>
</target>
</project>

+ 2
- 0
src/etc/testcases/types/filterseta.txt View File

@@ -0,0 +1,2 @@
This is a test file for filters @aaaa@
It has two lines @bbbb@

+ 5
- 0
src/etc/testcases/types/filtersetb.txt View File

@@ -0,0 +1,5 @@
This is a test file for filters with non default markers
@cccc@ - should not change
%cccc^ - should change
^dddd% - should not change
%dddd^ - should change

+ 7
- 0
src/etc/testcases/types/filtersetc.txt View File

@@ -0,0 +1,7 @@
Combined filter test
@aaaa@ - should change
@bbbb@ - should change
@cccc@ - should not change
%cccc^ - should change
^dddd% - should not change
%dddd^ - should change

+ 2
- 0
src/etc/testcases/types/gold/filterset1.txt View File

@@ -0,0 +1,2 @@
This is a test file for filters 1111
It has two lines 2222

+ 5
- 0
src/etc/testcases/types/gold/filterset2.txt View File

@@ -0,0 +1,5 @@
This is a test file for filters with non default markers
@cccc@ - should not change
3333 - should change
^dddd% - should not change
4444 - should change

+ 7
- 0
src/etc/testcases/types/gold/filterset3.txt View File

@@ -0,0 +1,7 @@
Combined filter test
1111 - should change
2222 - should change
@cccc@ - should not change
3333 - should change
^dddd% - should not change
4444 - should change

+ 9
- 8
src/main/org/apache/tools/ant/Main.java View File

@@ -69,7 +69,6 @@ import java.util.*;
* *
* @author duncan@x180.com * @author duncan@x180.com
*/ */

public class Main { public class Main {


/** The default build file name */ /** The default build file name */
@@ -132,7 +131,7 @@ public class Main {
* Entry point allowing for more options from other front ends * Entry point allowing for more options from other front ends
*/ */
public static void start(String[] args, Properties additionalUserProperties, public static void start(String[] args, Properties additionalUserProperties,
ClassLoader systemLoader) {
ClassLoader coreLoader) {
Main m = null; Main m = null;


try { try {
@@ -151,7 +150,7 @@ public class Main {
} }
try { try {
m.runBuild(systemLoader);
m.runBuild(coreLoader);
System.exit(0); System.exit(0);
} catch (BuildException be) { } catch (BuildException be) {
if (m.err != System.err) { if (m.err != System.err) {
@@ -390,7 +389,7 @@ public class Main {
/** /**
* Executes the build. * Executes the build.
*/ */
private void runBuild(ClassLoader systemLoader) throws BuildException {
private void runBuild(ClassLoader coreLoader) throws BuildException {


if (!readyToRun) { if (!readyToRun) {
return; return;
@@ -403,7 +402,7 @@ public class Main {
} }


final Project project = new Project(); final Project project = new Project();
project.setSystemLoader(systemLoader);
project.setCoreLoader(coreLoader);
Throwable error = null; Throwable error = null;


@@ -433,15 +432,17 @@ public class Main {
// first use the ProjectHelper to create the project object // first use the ProjectHelper to create the project object
// from the given build file. // from the given build file.
String noParserMessage =
"No JAXP compliant XML parser found. Please visit http://xml.apache.org for a suitable parser";
try { try {
Class.forName("javax.xml.parsers.SAXParserFactory"); Class.forName("javax.xml.parsers.SAXParserFactory");
ProjectHelper.configureProject(project, buildFile); ProjectHelper.configureProject(project, buildFile);
} catch (NoClassDefFoundError ncdfe) { } catch (NoClassDefFoundError ncdfe) {
throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", ncdfe);
throw new BuildException(noParserMessage, ncdfe);
} catch (ClassNotFoundException cnfe) { } catch (ClassNotFoundException cnfe) {
throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", cnfe);
throw new BuildException(noParserMessage, cnfe);
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", npe);
throw new BuildException(noParserMessage, npe);
} }
// make sure that we have a target to execute // make sure that we have a target to execute


+ 14
- 12
src/main/org/apache/tools/ant/Project.java View File

@@ -59,6 +59,7 @@ import java.util.*;
import java.text.*; import java.text.*;


import org.apache.tools.ant.types.FilterSet; import org.apache.tools.ant.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.util.FileUtils; import org.apache.tools.ant.util.FileUtils;


/** /**
@@ -108,12 +109,13 @@ public class Project {
private Hashtable taskClassDefinitions = new Hashtable(); private Hashtable taskClassDefinitions = new Hashtable();
private Hashtable targets = new Hashtable(); private Hashtable targets = new Hashtable();
private FilterSet globalFilterSet = new FilterSet(); private FilterSet globalFilterSet = new FilterSet();
private FilterSetCollection globalFilters = new FilterSetCollection(globalFilterSet);
private File baseDir; private File baseDir;


private Vector listeners = new Vector(); private Vector listeners = new Vector();


/** The system classloader - may be null */
private ClassLoader systemLoader = null;
/** The Ant core classloader - may be null if using system loader */
private ClassLoader coreLoader = null;


/** Records the latest task on a thread */ /** Records the latest task on a thread */
private Hashtable threadTasks = new Hashtable(); private Hashtable threadTasks = new Hashtable();
@@ -216,12 +218,12 @@ public class Project {
setSystemProperties(); setSystemProperties();
} }


public void setSystemLoader(ClassLoader systemLoader) {
this.systemLoader = systemLoader;
public void setCoreLoader(ClassLoader coreLoader) {
this.coreLoader = coreLoader;
} }
public ClassLoader getSystemLoader() {
return systemLoader;
public ClassLoader getCoreLoader() {
return coreLoader;
} }
public void addBuildListener(BuildListener listener) { public void addBuildListener(BuildListener listener) {
@@ -671,7 +673,7 @@ public class Project {
*/ */
public void copyFile(String sourceFile, String destFile, boolean filtering) public void copyFile(String sourceFile, String destFile, boolean filtering)
throws IOException { throws IOException {
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null);
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null);
} }


/** /**
@@ -685,7 +687,7 @@ public class Project {
*/ */
public void copyFile(String sourceFile, String destFile, boolean filtering, public void copyFile(String sourceFile, String destFile, boolean filtering,
boolean overwrite) throws IOException { boolean overwrite) throws IOException {
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null, overwrite);
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null, overwrite);
} }


/** /**
@@ -702,7 +704,7 @@ public class Project {
public void copyFile(String sourceFile, String destFile, boolean filtering, public void copyFile(String sourceFile, String destFile, boolean filtering,
boolean overwrite, boolean preserveLastModified) boolean overwrite, boolean preserveLastModified)
throws IOException { throws IOException {
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null,
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null,
overwrite, preserveLastModified); overwrite, preserveLastModified);
} }


@@ -728,7 +730,7 @@ public class Project {
*/ */
public void copyFile(File sourceFile, File destFile, boolean filtering) public void copyFile(File sourceFile, File destFile, boolean filtering)
throws IOException { throws IOException {
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null);
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null);
} }


/** /**
@@ -742,7 +744,7 @@ public class Project {
*/ */
public void copyFile(File sourceFile, File destFile, boolean filtering, public void copyFile(File sourceFile, File destFile, boolean filtering,
boolean overwrite) throws IOException { boolean overwrite) throws IOException {
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null, overwrite);
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null, overwrite);
} }


/** /**
@@ -759,7 +761,7 @@ public class Project {
public void copyFile(File sourceFile, File destFile, boolean filtering, public void copyFile(File sourceFile, File destFile, boolean filtering,
boolean overwrite, boolean preserveLastModified) boolean overwrite, boolean preserveLastModified)
throws IOException { throws IOException {
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null,
fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null,
overwrite, preserveLastModified); overwrite, preserveLastModified);
} }




+ 3
- 2
src/main/org/apache/tools/ant/listener/Log4jListener.java View File

@@ -73,7 +73,8 @@ public class Log4jListener implements BuildListener {
public Log4jListener() { public Log4jListener() {
initialized = false; initialized = false;
Category cat = Category.getInstance("org.apache.tools.ant"); Category cat = Category.getInstance("org.apache.tools.ant");
if (!(cat.getAllAppenders() instanceof NullEnumeration)) {
Category rootCat = Category.getRoot();
if (!(rootCat.getAllAppenders() instanceof NullEnumeration)) {
initialized = true; initialized = true;
} }
else { else {
@@ -90,7 +91,7 @@ public class Log4jListener implements BuildListener {
public void buildFinished(BuildEvent event) { public void buildFinished(BuildEvent event) {
if (initialized) { if (initialized) {
Category cat = Category.getInstance(Target.class.getName());
Category cat = Category.getInstance(Project.class.getName());
if (event.getException() == null) { if (event.getException() == null) {
cat.info("Build finished."); cat.info("Build finished.");
} }


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/Copy.java View File

@@ -365,14 +365,14 @@ public class Copy extends Task {
try { try {
log("Copying " + fromFile + " to " + toFile, verbosity); log("Copying " + fromFile + " to " + toFile, verbosity);
FilterSet executionFilterSet = new FilterSet();
FilterSetCollection executionFilters = new FilterSetCollection();
if (filtering) { if (filtering) {
executionFilterSet.addFilterSet(project.getGlobalFilterSet());
executionFilters.addFilterSet(project.getGlobalFilterSet());
} }
for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) { for (Enumeration filterEnum = filterSets.elements(); filterEnum.hasMoreElements();) {
executionFilterSet.addFilterSet((FilterSet)filterEnum.nextElement());
executionFilters.addFilterSet((FilterSet)filterEnum.nextElement());
} }
fileUtils.copyFile(fromFile, toFile, executionFilterSet,
fileUtils.copyFile(fromFile, toFile, executionFilters,
forceOverwrite, preserveLastModified); forceOverwrite, preserveLastModified);
} catch (IOException ioe) { } catch (IOException ioe) {
String msg = "Failed to copy " + fromFile + " to " + toFile String msg = "Failed to copy " + fromFile + " to " + toFile


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/DependSet.java View File

@@ -187,7 +187,7 @@ public class DependSet extends MatchingTask {
for (int i = 0; i < targetFiles.length; i++) { for (int i = 0; i < targetFiles.length; i++) {
File dest = new File(targetFS.getDir(project), targetFiles[i]); File dest = new File(targetFS.getDir(project), targetFiles[i]);
allTargets.add(dest);
allTargets.addElement(dest);


if (dest.lastModified() > now) { if (dest.lastModified() > now) {
log("Warning: "+targetFiles[i]+" modified in the future.", log("Warning: "+targetFiles[i]+" modified in the future.",
@@ -215,7 +215,7 @@ public class DependSet extends MatchingTask {
continue; continue;
} }
else { else {
allTargets.add(dest);
allTargets.addElement(dest);
} }
if (dest.lastModified() > now) { if (dest.lastModified() > now) {
log("Warning: "+targetFiles[i]+" modified in the future.", log("Warning: "+targetFiles[i]+" modified in the future.",


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java View File

@@ -114,7 +114,7 @@ public class ExecuteJava {
if (classpath == null) { if (classpath == null) {
target = Class.forName(classname); target = Class.forName(classname);
} else { } else {
loader = new AntClassLoader(project.getSystemLoader(), project, classpath, false);
loader = new AntClassLoader(project.getCoreLoader(), project, classpath, false);
loader.setIsolated(true); loader.setIsolated(true);
loader.setThreadContextLoader(); loader.setThreadContextLoader();
target = loader.forceLoadClass(classname); target = loader.forceLoadClass(classname);


+ 10
- 1
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -70,7 +70,9 @@ public class Jar extends Zip {


private File manifestFile; private File manifestFile;
private Manifest manifest; private Manifest manifest;
private Manifest execManifest;
private Manifest execManifest;
/** true if a manifest has been specified in the task */
private boolean buildFileManifest = false; private boolean buildFileManifest = false;
public Jar() { public Jar() {
@@ -279,15 +281,22 @@ public class Jar extends Zip {
theZipFile = new java.util.zip.ZipFile(zipFile); theZipFile = new java.util.zip.ZipFile(zipFile);
java.util.zip.ZipEntry entry = theZipFile.getEntry("META-INF/MANIFEST.MF"); java.util.zip.ZipEntry entry = theZipFile.getEntry("META-INF/MANIFEST.MF");
if (entry == null) { if (entry == null) {
log("Updating jar since the current jar has no manifest", Project.MSG_VERBOSE);
return false; return false;
} }
Manifest currentManifest = new Manifest(theZipFile.getInputStream(entry)); Manifest currentManifest = new Manifest(theZipFile.getInputStream(entry));
if (manifest == null) {
manifest = getDefaultManifest();
}
if (!currentManifest.equals(manifest)) { if (!currentManifest.equals(manifest)) {
log("Updating jar since jar manifest has changed", Project.MSG_VERBOSE);
return false; return false;
} }
} }
catch (Exception e) { catch (Exception e) {
// any problems and we will rebuild // any problems and we will rebuild
log("Updating jar since cannot read current jar manifest: " + e.getClass().getName() + e.getMessage(),
Project.MSG_VERBOSE);
return false; return false;
} }
finally { finally {


+ 15
- 0
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -115,6 +115,7 @@ public class Javac extends MatchingTask {
private boolean includeAntRuntime = true; private boolean includeAntRuntime = true;
private boolean includeJavaRuntime = false; private boolean includeJavaRuntime = false;
private boolean fork = false; private boolean fork = false;
private boolean nowarn = false;


protected boolean failOnError = true; protected boolean failOnError = true;
protected File[] compileList = new File[0]; protected File[] compileList = new File[0];
@@ -410,6 +411,20 @@ public class Javac extends MatchingTask {
} }


/**
* Sets whether the -nowarn option should be used.
*/
public void setNowarn(boolean flag) {
this.nowarn = flag;
}

/**
* Should the -nowarn option be used.
*/
public boolean getNowarn() {
return nowarn;
}

/** /**
* Executes the task. * Executes the task.
*/ */


+ 3
- 2
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -681,9 +681,10 @@ public class Javadoc extends Task {
public String getPackages() { public String getPackages() {
StringBuffer p = new StringBuffer( "\"" ); StringBuffer p = new StringBuffer( "\"" );
for (int i = 0; i < packages.size(); i++) { for (int i = 0; i < packages.size(); i++) {
p.append( packages.elementAt( i ).toString() );
if ( i > 0 )
if ( i > 0 ) {
p.append( ":" ); p.append( ":" );
}
p.append( packages.elementAt(i).toString() );
} }
p.append( "\"" ); p.append( "\"" );
return p.toString(); return p.toString();


+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/Move.java View File

@@ -123,14 +123,14 @@ public class Move extends Copy {
try { try {
log("Moving " + fromFile + " to " + toFile, verbosity); log("Moving " + fromFile + " to " + toFile, verbosity);
FilterSet executionFilterSet = new FilterSet();
FilterSetCollection executionFilters = new FilterSetCollection();
if (filtering) { if (filtering) {
executionFilterSet.addFilterSet(project.getGlobalFilterSet());
executionFilters.addFilterSet(project.getGlobalFilterSet());
} }
for (Enumeration filterEnum = getFilterSets().elements(); filterEnum.hasMoreElements();) { for (Enumeration filterEnum = getFilterSets().elements(); filterEnum.hasMoreElements();) {
executionFilterSet.addFilterSet((FilterSet)filterEnum.nextElement());
executionFilters.addFilterSet((FilterSet)filterEnum.nextElement());
} }
getFileUtils().copyFile(f, d, executionFilterSet,
getFileUtils().copyFile(f, d, executionFilters,
forceOverwrite); forceOverwrite);
f = new File(fromFile); f = new File(fromFile);


+ 36
- 4
src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java View File

@@ -54,19 +54,51 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.*;
import java.io.File;


/** /**
* Proxy interface for XSLT processors.
* *
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @version $Revision$ $Date$
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
* @see #XSLTProcess
*/ */
public interface XSLTLiaison { public interface XSLTLiaison {


public void setStylesheet(String fileName) throws Exception;
/**
* the file protocol prefix for systemid.
* This file protocol must be appended to an absolute path.
* Typically: <tt>FILE_PROTOCOL_PREFIX + file.getAbsolutePath()</tt>
* This is not correct in specification terms since an absolute
* url in Unix is file:// + file.getAbsolutePath() while it is
* file:/// + file.getAbsolutePath() under Windows.
* Whatever, it should not be a problem to put file:/// in every
* case since most parsers for now incorrectly makes no difference
* between it.. and users also have problem with that :)
*/
public final static String FILE_PROTOCOL_PREFIX = "file:///";


/**
* set the stylesheet to use for the transformation.
* @param stylesheet the stylesheet to be used for transformation.
*/
public void setStylesheet(File stylesheet) throws Exception;

/**
* Add a parameter to be set during the XSL transformation.
* @param name the parameter name.
* @param expression the parameter value as an expression string.
* @throws Exception thrown if any problems happens.
*/
public void addParam(String name, String expression) throws Exception; public void addParam(String name, String expression) throws Exception;


public void transform(String infile, String outfile) throws Exception;
/**
* Perform the transformation of a file into another.
* @param infile the input file, probably an XML one. :-)
* @param outfile the output file resulting from the transformation
* @throws Exception thrown if any problems happens.
* @see #setStylesheet(File)
*/
public void transform(File infile, File outfile) throws Exception;


} //-- XSLTLiaison } //-- XSLTLiaison

+ 19
- 19
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -100,9 +100,9 @@ public class XSLTProcess extends MatchingTask {


private String targetExtension = ".html"; private String targetExtension = ".html";
private Vector params = new Vector(); private Vector params = new Vector();
private File inFile = null; private File inFile = null;
private File outFile = null; private File outFile = null;


private String processor; private String processor;
@@ -137,7 +137,7 @@ public class XSLTProcess extends MatchingTask {
if (baseDir == null) { if (baseDir == null) {
baseDir = project.resolveFile("."); baseDir = project.resolveFile(".");
} }
liaison = getLiaison(); liaison = getLiaison();
log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE); log("Using "+liaison.getClass().toString(), Project.MSG_VERBOSE);


@@ -178,7 +178,7 @@ public class XSLTProcess extends MatchingTask {
for (int i = 0;i < list.length; ++i) { for (int i = 0;i < list.length; ++i) {
process( baseDir, list[i], destDir, stylesheet ); process( baseDir, list[i], destDir, stylesheet );
} }
// Process all the directoried marked for styling // Process all the directoried marked for styling
dirs = scanner.getIncludedDirectories(); dirs = scanner.getIncludedDirectories();
for (int j = 0;j < dirs.length;++j){ for (int j = 0;j < dirs.length;++j){
@@ -264,15 +264,15 @@ public class XSLTProcess extends MatchingTask {
*/ */
private void resolveProcessor(String proc) throws Exception { private void resolveProcessor(String proc) throws Exception {
if (proc.equals("trax")) { if (proc.equals("trax")) {
final Class clazz =
final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.TraXLiaison"); loadClass("org.apache.tools.ant.taskdefs.optional.TraXLiaison");
liaison = (XSLTLiaison)clazz.newInstance(); liaison = (XSLTLiaison)clazz.newInstance();
} else if (proc.equals("xslp")) { } else if (proc.equals("xslp")) {
final Class clazz =
final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.XslpLiaison"); loadClass("org.apache.tools.ant.taskdefs.optional.XslpLiaison");
liaison = (XSLTLiaison) clazz.newInstance(); liaison = (XSLTLiaison) clazz.newInstance();
} else if (proc.equals("xalan")) { } else if (proc.equals("xalan")) {
final Class clazz =
final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.XalanLiaison"); loadClass("org.apache.tools.ant.taskdefs.optional.XalanLiaison");
liaison = (XSLTLiaison)clazz.newInstance(); liaison = (XSLTLiaison)clazz.newInstance();
} else { } else {
@@ -313,14 +313,14 @@ public class XSLTProcess extends MatchingTask {
* Processes the given input XML file and stores the result * Processes the given input XML file and stores the result
* in the given resultFile. * in the given resultFile.
**/ **/
private void process(File baseDir, String xmlFile, File destDir,
private void process(File baseDir, String xmlFile, File destDir,
File stylesheet) File stylesheet)
throws BuildException { throws BuildException {


String fileExt=targetExtension; String fileExt=targetExtension;
File outFile=null; File outFile=null;
File inFile=null; File inFile=null;
try { try {
long styleSheetLastModified = stylesheet.lastModified(); long styleSheetLastModified = stylesheet.lastModified();
inFile = new File(baseDir,xmlFile); inFile = new File(baseDir,xmlFile);
@@ -337,7 +337,7 @@ public class XSLTProcess extends MatchingTask {
log("Transforming into "+destDir); log("Transforming into "+destDir);


configureLiaison(stylesheet); configureLiaison(stylesheet);
liaison.transform(inFile.toString(), outFile.toString());
liaison.transform(inFile, outFile);
} }
} }
catch (Exception ex) { catch (Exception ex) {
@@ -347,7 +347,7 @@ public class XSLTProcess extends MatchingTask {
if (outFile != null) { if (outFile != null) {
outFile.delete(); outFile.delete();
} }
throw new BuildException(ex); throw new BuildException(ex);
} }


@@ -365,7 +365,7 @@ public class XSLTProcess extends MatchingTask {
ensureDirectoryFor( outFile ); ensureDirectoryFor( outFile );
log("Processing " + inFile + " to " + outFile, Project.MSG_INFO); log("Processing " + inFile + " to " + outFile, Project.MSG_INFO);
configureLiaison(stylesheet); configureLiaison(stylesheet);
liaison.transform(inFile.toString(), outFile.toString());
liaison.transform(inFile, outFile);
} }
}catch (Exception ex) { }catch (Exception ex) {
log("Failed to process " + inFile, Project.MSG_INFO); log("Failed to process " + inFile, Project.MSG_INFO);
@@ -378,12 +378,12 @@ public class XSLTProcess extends MatchingTask {
File directory = new File( targetFile.getParent() ); File directory = new File( targetFile.getParent() );
if (!directory.exists()) { if (!directory.exists()) {
if (!directory.mkdirs()) { if (!directory.mkdirs()) {
throw new BuildException("Unable to create directory: "
throw new BuildException("Unable to create directory: "
+ directory.getAbsolutePath() ); + directory.getAbsolutePath() );
} }
} }
} }
protected XSLTLiaison getLiaison() { protected XSLTLiaison getLiaison() {
// if processor wasn't specified, see if TraX is available. If not, // if processor wasn't specified, see if TraX is available. If not,
// default it to xslp or xalan, depending on which is in the classpath // default it to xslp or xalan, depending on which is in the classpath
@@ -424,20 +424,20 @@ public class XSLTProcess extends MatchingTask {
public class Param { public class Param {
private String name=null; private String name=null;
private String expression=null; private String expression=null;
public void setName(String name){ public void setName(String name){
this.name = name; this.name = name;
} }
public void setExpression(String expression){ public void setExpression(String expression){
this.expression = expression; this.expression = expression;
} }
public String getName() throws BuildException{ public String getName() throws BuildException{
if(name==null)throw new BuildException("Name attribute is missing."); if(name==null)throw new BuildException("Name attribute is missing.");
return name; return name;
} }
public String getExpression() throws BuildException{ public String getExpression() throws BuildException{
if(expression==null)throw new BuildException("Expression attribute is missing."); if(expression==null)throw new BuildException("Expression attribute is missing.");
return expression; return expression;
@@ -455,7 +455,7 @@ public class XSLTProcess extends MatchingTask {


try { try {
log( "Loading stylesheet " + stylesheet, Project.MSG_INFO); log( "Loading stylesheet " + stylesheet, Project.MSG_INFO);
liaison.setStylesheet( stylesheet.toString() );
liaison.setStylesheet( stylesheet );
for(Enumeration e = params.elements();e.hasMoreElements();) { for(Enumeration e = params.elements();e.hasMoreElements();) {
Param p = (Param)e.nextElement(); Param p = (Param)e.nextElement();
liaison.addParam( p.getName(), p.getExpression() ); liaison.addParam( p.getName(), p.getExpression() );


+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java View File

@@ -206,6 +206,10 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
protected Commandline setupJavacCommandlineSwitches(Commandline cmd) { protected Commandline setupJavacCommandlineSwitches(Commandline cmd) {
Path classpath = getCompileClasspath(); Path classpath = getCompileClasspath();


if (attributes.getNowarn()) {
cmd.createArgument().setValue("-nowarn");
}
if (deprecation == true) { if (deprecation == true) {
cmd.createArgument().setValue("-deprecation"); cmd.createArgument().setValue("-deprecation");
} }


+ 15
- 1
src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java View File

@@ -173,7 +173,21 @@ public class Jikes extends DefaultCompilerAdapter {
* warning can be pretty annoying. * warning can be pretty annoying.
*/ */
String warningsProperty = project.getProperty("build.compiler.warnings"); String warningsProperty = project.getProperty("build.compiler.warnings");
if (warningsProperty != null && !Project.toBoolean(warningsProperty)) {
if (warningsProperty != null) {
attributes.log("!! the build.compiler.warnings property is deprecated. !!",
Project.MSG_WARN);
attributes.log("!! Use the nowarn attribute instead. !!",
Project.MSG_WARN);
if (!Project.toBoolean(warningsProperty)) {
cmd.createArgument().setValue("-nowarn");
}
} if (attributes.getNowarn()) {
/*
* FIXME later
*
* let the magic property win over the attribute for backwards
* compatibility
*/
cmd.createArgument().setValue("-nowarn"); cmd.createArgument().setValue("-nowarn");
} }




+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/defaults.properties View File

@@ -113,8 +113,8 @@ vsscheckout=org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKOUT
iplanet-ejbc=org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask iplanet-ejbc=org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask
jdepend=org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask jdepend=org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask
mimemail=org.apache.tools.ant.taskdefs.optional.net.MimeMail mimemail=org.apache.tools.ant.taskdefs.optional.net.MimeMail
cccheckin=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin
cccheckout=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout
ccmcheckin=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckin
ccmcheckout=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckout
ccmcheckintask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckinDefault ccmcheckintask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCheckinDefault
ccmreconfigure=org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure ccmreconfigure=org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure
ccmcreatetask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask ccmcreatetask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask


+ 67
- 19
src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java View File

@@ -54,61 +54,109 @@


package org.apache.tools.ant.taskdefs.optional; package org.apache.tools.ant.taskdefs.optional;


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException;


import org.apache.tools.ant.taskdefs.XSLTLiaison; import org.apache.tools.ant.taskdefs.XSLTLiaison;


import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer; import javax.xml.transform.Transformer;
import javax.xml.transform.Templates; import javax.xml.transform.Templates;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource; import javax.xml.transform.stream.StreamSource;


/** /**
* Concrete liaison for XSLT processor implementing TraX. (ie JAXP 1.1)
* *
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a> * @author <a href="mailto:dims@yahoo.com">Davanum Srinivas</a>
* @version $Revision$ $Date$
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
*/ */
public class TraXLiaison implements XSLTLiaison { public class TraXLiaison implements XSLTLiaison {


protected final static String FILEURL = "file:";

/** The trax TransformerFactory */ /** The trax TransformerFactory */
private TransformerFactory tfactory = null; private TransformerFactory tfactory = null;


/** stylesheet stream, close it asap */
private FileInputStream xslStream = null;

/** Stylesheet template */ /** Stylesheet template */
private Templates templates = null; private Templates templates = null;


/** The trax Transformer itself */
private Transformer transformer;
/** transformer */
private Transformer transformer = null;


public TraXLiaison() throws Exception { public TraXLiaison() throws Exception {
tfactory = TransformerFactory.newInstance(); tfactory = TransformerFactory.newInstance();
} }
//------------------- IMPORTANT
// 1) Don't use the StreamSource(File) ctor. It won't work with
// xalan prior to 2.2 because of systemid bugs.

// 2) Use a stream so that you can close it yourself quickly
// and avoid keeping the handle until the object is garbaged.
// (always keep control), otherwise you won't be able to delete
// the file quickly on windows.

// 3) Always set the systemid to the source for imports, includes...
// in xsl and xml...


public void setStylesheet(String fileName) throws Exception {
templates = tfactory.newTemplates(new StreamSource(normalize(fileName)));
public void setStylesheet(File stylesheet) throws Exception {
xslStream = new FileInputStream(stylesheet);
StreamSource src = new StreamSource(xslStream);
src.setSystemId(getSystemId(stylesheet));
templates = tfactory.newTemplates(src);
transformer = templates.newTransformer(); transformer = templates.newTransformer();
};
}


public void transform(String infile, String outfile) throws Exception {
FileOutputStream out = new FileOutputStream(outfile);
public void transform(File infile, File outfile) throws Exception {
FileInputStream fis = null;
FileOutputStream fos = null;
try { try {
transformer.transform(new StreamSource(normalize(infile)),
new StreamResult(out));
fis = new FileInputStream(infile);
fos = new FileOutputStream(outfile);
StreamSource src = new StreamSource(fis);
src.setSystemId(getSystemId(infile));
StreamResult res = new StreamResult(fos);
// not sure what could be the need of this...
res.setSystemId(getSystemId(outfile));

transformer.transform(src, res);
} finally { } finally {
out.close();
// make sure to close all handles, otherwise the garbage
// collector will close them...whenever possible and
// Windows may complain about not being able to delete files.
try {
if (xslStream != null){
xslStream.close();
}
} catch (IOException ignored){}
try {
if (fis != null){
fis.close();
}
} catch (IOException ignored){}
try {
if (fos != null){
fos.close();
}
} catch (IOException ignored){}
} }
} }


protected String normalize(String fileName) {
if(fileName != null && !fileName.startsWith(FILEURL)) {
return FILEURL + "///" + fileName;
}
return fileName;
// make sure that the systemid is made of '/' and not '\' otherwise
// crimson will complain that it cannot resolve relative entities
// because it grabs the base uri via lastIndexOf('/') without
// making sure it is really a /'ed path
protected String getSystemId(File file){
String path = file.getAbsolutePath();
path = path.replace('\\','/');
return FILE_PROTOCOL_PREFIX + path;
} }
public void addParam(String name, String value){ public void addParam(String name, String value){
transformer.setParameter(name, value); transformer.setParameter(name, value);
} }


+ 48
- 17
src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java View File

@@ -60,39 +60,70 @@ import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTProcessor; import org.apache.xalan.xslt.XSLTProcessor;
import org.apache.xalan.xslt.XSLTInputSource; import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget; import org.apache.xalan.xslt.XSLTResultTarget;
import org.xml.sax.InputSource;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;


/** /**
* Concrete liaison for Xalan 1.x API.
* *
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @version $Revision$ $Date$
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
*/ */
public class XalanLiaison implements XSLTLiaison { public class XalanLiaison implements XSLTLiaison {


protected final static String FILEURL = "file:";

XSLTProcessor processor;
XSLTInputSource xslSheet;
protected XSLTProcessor processor;
protected File stylesheet;


public XalanLiaison() throws Exception { public XalanLiaison() throws Exception {
processor = XSLTProcessorFactory.getProcessor(); processor = XSLTProcessorFactory.getProcessor();
} }


public void setStylesheet(String fileName) throws Exception {
xslSheet = new XSLTInputSource (normalize(fileName));
};

public void transform(String infile, String outfile) throws Exception {
processor.process(new XSLTInputSource(normalize(infile)), xslSheet,
new XSLTResultTarget(outfile));
public void setStylesheet(File stylesheet) throws Exception {
this.stylesheet = stylesheet;
} }


protected String normalize(String fileName) {
if(fileName != null && !fileName.startsWith(FILEURL)) {
return FILEURL + fileName;
public void transform(File infile, File outfile) throws Exception {
FileInputStream fis = null;
FileOutputStream fos = null;
FileInputStream xslStream = null;
try {
xslStream = new FileInputStream(stylesheet);
fis = new FileInputStream(infile);
fos = new FileOutputStream(outfile);
// systemid such as file:/// + getAbsolutePath() are considered
// invalid here...
XSLTInputSource xslSheet = new XSLTInputSource(xslStream);
xslSheet.setSystemId(stylesheet.getAbsolutePath());
XSLTInputSource src = new XSLTInputSource(fis);
src.setSystemId(infile.getAbsolutePath());
XSLTResultTarget res = new XSLTResultTarget(fos);
processor.process(src, xslSheet, res);
} finally {
// make sure to close all handles, otherwise the garbage
// collector will close them...whenever possible and
// Windows may complain about not being able to delete files.
try {
if (xslStream != null){
xslStream.close();
}
} catch (IOException ignored){}
try {
if (fis != null){
fis.close();
}
} catch (IOException ignored){}
try {
if (fos != null){
fos.close();
}
} catch (IOException ignored){}
} }
return fileName;
} }
public void addParam(String name, String value){ public void addParam(String name, String value){
processor.setStylesheetParam(name, value); processor.setStylesheetParam(name, value);
} }


+ 22
- 17
src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java View File

@@ -54,40 +54,45 @@


package org.apache.tools.ant.taskdefs.optional; package org.apache.tools.ant.taskdefs.optional;


import java.io.FileWriter;
import java.io.*;
import java.net.URL;


import org.apache.tools.ant.taskdefs.XSLTLiaison; import org.apache.tools.ant.taskdefs.XSLTLiaison;
import org.xml.sax.InputSource;


import com.kvisco.xsl.XSLProcessor;
import com.kvisco.xsl.XSLReader;
import com.kvisco.xsl.XSLStylesheet;
import com.kvisco.xsl.*;


/** /**
* Concrete liaison for XSLP
* *
* @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a>
* @version $Revision$ $Date$
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
*/ */
public class XslpLiaison implements XSLTLiaison { public class XslpLiaison implements XSLTLiaison {


XSLProcessor processor;
XSLStylesheet xslSheet;
protected XSLProcessor processor;
protected XSLStylesheet xslSheet;


public XslpLiaison() { public XslpLiaison() {
processor = new XSLProcessor(); processor = new XSLProcessor();
// uh ?! I'm forced to do that otherwise a setProperty crashes with NPE !
// I don't understand why the property map is static though...
// how can we do multithreading w/ multiple identical parameters ?
processor.getProperty("dummy-to-init-properties-map");
} }


public void setStylesheet(String fileName) throws Exception {
public void setStylesheet(File fileName) throws Exception {
XSLReader xslReader = new XSLReader(); XSLReader xslReader = new XSLReader();
xslSheet = xslReader.read( fileName );
};
// a file:/// + getAbsolutePath() does not work here
// it is really the pathname
xslSheet = xslReader.read( fileName.getAbsolutePath() );
}


public void transform(String infile, String outfile) throws Exception {
FileWriter out = new FileWriter(outfile);
try {
processor.process(infile, xslSheet, out);
} finally {
out.close();
}
public void transform(File infile, File outfile) throws Exception {
FileOutputStream fos = new FileOutputStream(outfile);
// XSLP does not support encoding...we're in hot water.
OutputStreamWriter out = new OutputStreamWriter(fos,"UTF8");
processor.process(infile.getAbsolutePath(), xslSheet, out);
} }


public void addParam(String name, String expression){ public void addParam(String name, String expression){


+ 96
- 47
src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java View File

@@ -137,6 +137,12 @@ public class Depend extends MatchingTask {
/** The classpath to look for additional dependencies */ /** The classpath to look for additional dependencies */
private Path dependClasspath; private Path dependClasspath;


/**
* constants used with the cache file
*/
private final static String CACHE_FILE_NAME = "dependencies.txt";
private final static String CLASSNAME_PREPEND = "||:";

/** /**
* Set the classpath to be used for this dependency check. * Set the classpath to be used for this dependency check.
*/ */
@@ -169,46 +175,74 @@ public class Depend extends MatchingTask {
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
createClasspath().setRefid(r); createClasspath().setRefid(r);
} }
private void writeDependencyList(File depFile, Vector dependencyList) throws IOException {
// new dependencies so need to write them out to the cache
PrintWriter pw = null;
try {
String parent = depFile.getParent();
if (parent != null) {
new File(parent).mkdirs();
}
pw = new PrintWriter(new FileWriter(depFile));
for (Enumeration deps = dependencyList.elements(); deps.hasMoreElements();) {
pw.println(deps.nextElement());
}
}
finally {
if (pw != null) {
pw.close();
/**
* Read the dependencies from cache file
*/
private Hashtable readCachedDependencies() throws IOException{
Hashtable dependencyMap = new Hashtable();
if (cache != null) {
File depFile = new File(cache, CACHE_FILE_NAME);
BufferedReader in = null;
if (depFile.exists()) {
try {
in = new BufferedReader(new FileReader(depFile));
String line = null;
Vector dependencyList = null;
String className = null;
int prependLength = CLASSNAME_PREPEND.length();
while ((line = in.readLine()) != null) {
if (line.startsWith(CLASSNAME_PREPEND)) {
dependencyList = new Vector();
className = line.substring(prependLength);
dependencyMap.put(className, dependencyList);
}
else {
dependencyList.addElement(line);
}
}
}
finally {
if (in != null) {
in.close();
}
}
} }
} }
return dependencyMap;
} }

private Vector readDependencyList(File depFile) throws IOException {
Vector dependencyList = null;
BufferedReader in = null;
try {
in = new BufferedReader(new FileReader(depFile));
String line = null;
dependencyList = new Vector();
while ((line = in.readLine()) != null) {
dependencyList.addElement(line);
/**
* Write the dependencies to cache file
*/
private void writeCachedDependencies(Hashtable dependencyMap) throws IOException{
if (cache != null) {
PrintWriter pw = null;
try {
cache.mkdirs();
File depFile = new File(cache, CACHE_FILE_NAME);
pw = new PrintWriter(new FileWriter(depFile));
for (Enumeration deps = dependencyMap.keys(); deps.hasMoreElements();) {
String className = (String)deps.nextElement();
pw.println(CLASSNAME_PREPEND + className);
Vector dependencyList = (Vector)dependencyMap.get(className);
int size = dependencyList.size();
for (int x = 0; x < size; x++) {
pw.println(dependencyList.elementAt(x));
}
}
} }
}
finally {
if (in != null) {
in.close();
finally {
if (pw != null) {
pw.close();
}
} }
} }
return dependencyList;
} }




@@ -221,7 +255,20 @@ public class Depend extends MatchingTask {
private void determineDependencies() throws IOException { private void determineDependencies() throws IOException {
affectedClassMap = new Hashtable(); affectedClassMap = new Hashtable();
classFileInfoMap = new Hashtable(); classFileInfoMap = new Hashtable();
Hashtable dependencyMap = new Hashtable();
boolean cacheDirty = false;
Hashtable dependencyMap = null;
File depCacheFile = null;
boolean depCacheFileExists = true;
long depCacheFileLastModified = Long.MAX_VALUE;
// read the dependency cache from the disk
if (cache != null) {
dependencyMap = readCachedDependencies();
depCacheFile = new File(cache, CACHE_FILE_NAME);
depCacheFileExists = depCacheFile.exists();
depCacheFileLastModified = depCacheFile.lastModified();
}
for (Enumeration e = getClassFiles(destPath).elements(); e.hasMoreElements(); ) { for (Enumeration e = getClassFiles(destPath).elements(); e.hasMoreElements(); ) {
ClassFileInfo info = (ClassFileInfo)e.nextElement(); ClassFileInfo info = (ClassFileInfo)e.nextElement();
log("Adding class info for " + info.className, Project.MSG_DEBUG); log("Adding class info for " + info.className, Project.MSG_DEBUG);
@@ -230,12 +277,11 @@ public class Depend extends MatchingTask {
Vector dependencyList = null; Vector dependencyList = null;
if (cache != null) { if (cache != null) {
// try to read the dependency info from the cache if it is not out of date
File depFile = new File(cache, info.relativeName + ".dep");
if (depFile.exists() && depFile.lastModified() > info.absoluteFile.lastModified()) {
// try to read the dependency info from the map if it is not out of date
if (depCacheFileExists && depCacheFileLastModified > info.absoluteFile.lastModified()) {
// depFile exists and is newer than the class file // depFile exists and is newer than the class file
// need to read dependency list from the file.
dependencyList = readDependencyList(depFile);
// need to get dependency list from the map.
dependencyList = (Vector)dependencyMap.get(info.className);
} }
} }
@@ -248,12 +294,11 @@ public class Depend extends MatchingTask {
classFile.read(inFileStream); classFile.read(inFileStream);
dependencyList = classFile.getClassRefs(); dependencyList = classFile.getClassRefs();
if (cache != null) {
// new dependencies so need to write them out to the cache
File depFile = new File(cache, info.relativeName + ".dep");
writeDependencyList(depFile, dependencyList);
if (dependencyList != null) {
cacheDirty = true;
dependencyMap.put(info.className, dependencyList);
} }
} }
finally { finally {
if (inFileStream != null) { if (inFileStream != null) {
@@ -261,8 +306,7 @@ public class Depend extends MatchingTask {
} }
} }
} }
dependencyMap.put(info.className, dependencyList);
// This class depends on each class in the dependency list. For each // This class depends on each class in the dependency list. For each
// one of those, add this class into their affected classes list // one of those, add this class into their affected classes list
for (Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) { for (Enumeration depEnum = dependencyList.elements(); depEnum.hasMoreElements(); ) {
@@ -326,6 +370,11 @@ public class Depend extends MatchingTask {
} }
} }
} }
// write the dependency cache to the disk
if (cache != null && cacheDirty) {
writeCachedDependencies(dependencyMap);
}
} }
private int deleteAllAffectedFiles() { private int deleteAllAffectedFiles() {


+ 14
- 3
src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java View File

@@ -87,6 +87,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
* Bunch of constants used for storing entries in a hashtable, and for * Bunch of constants used for storing entries in a hashtable, and for
* constructing the filenames of various parts of the ejb jar. * constructing the filenames of various parts of the ejb jar.
*/ */
private static final String EJB_REF = "ejb-ref";
private static final String HOME_INTERFACE = "home"; private static final String HOME_INTERFACE = "home";
private static final String REMOTE_INTERFACE = "remote"; private static final String REMOTE_INTERFACE = "remote";
private static final String BEAN_CLASS = "ejb-class"; private static final String BEAN_CLASS = "ejb-class";
@@ -130,6 +131,8 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
private Hashtable resourceDTDs = new Hashtable(); private Hashtable resourceDTDs = new Hashtable();


private boolean inEJBRef = false;

private Hashtable urlDTDs = new Hashtable(); private Hashtable urlDTDs = new Hashtable();


/** /**
@@ -244,6 +247,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
public void startDocument() throws SAXException { public void startDocument() throws SAXException {
this.ejbFiles = new Hashtable(10, 1); this.ejbFiles = new Hashtable(10, 1);
this.currentElement = null; this.currentElement = null;
inEJBRef = false;
} }




@@ -258,7 +262,10 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
throws SAXException { throws SAXException {
this.currentElement = name; this.currentElement = name;
currentText = ""; currentText = "";
if (parseState == STATE_LOOKING_EJBJAR && name.equals(EJB_JAR)) {
if (name.equals(EJB_REF)) {
inEJBRef = true;
}
else if (parseState == STATE_LOOKING_EJBJAR && name.equals(EJB_JAR)) {
parseState = STATE_IN_EJBJAR; parseState = STATE_IN_EJBJAR;
} }
else if (parseState == STATE_IN_EJBJAR && name.equals(ENTERPRISE_BEANS)) { else if (parseState == STATE_IN_EJBJAR && name.equals(ENTERPRISE_BEANS)) {
@@ -286,7 +293,10 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
processElement(); processElement();
currentText = ""; currentText = "";
this.currentElement = ""; this.currentElement = "";
if (parseState == STATE_IN_ENTITY && name.equals(ENTITY_BEAN )) {
if (name.equals(EJB_REF)) {
inEJBRef = false;
}
else if (parseState == STATE_IN_ENTITY && name.equals(ENTITY_BEAN )) {
parseState = STATE_IN_BEANS; parseState = STATE_IN_BEANS;
} }
else if (parseState == STATE_IN_SESSION && name.equals(SESSION_BEAN)) { else if (parseState == STATE_IN_SESSION && name.equals(SESSION_BEAN)) {
@@ -323,7 +333,8 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
protected void processElement() { protected void processElement() {
if (parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION) {
if (inEJBRef ||
(parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION)) {
return; return;
} }


+ 3
- 4
src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java View File

@@ -263,12 +263,11 @@ public class WLRun extends Task {


File propertiesFile = null; File propertiesFile = null;

if (weblogicPropertiesFile == null) { if (weblogicPropertiesFile == null) {
propertiesFile = new File(weblogicSystemHome, DEFAULT_PROPERTIES_FILE);
}
else {
propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile);
weblogicPropertiesFile = DEFAULT_PROPERTIES_FILE;
} }
propertiesFile = new File(weblogicSystemHome, weblogicPropertiesFile);
if (!propertiesFile.exists()) { if (!propertiesFile.exists()) {
// OK, properties file may be absolute // OK, properties file may be absolute
propertiesFile = project.resolveFile(weblogicPropertiesFile); propertiesFile = project.resolveFile(weblogicPropertiesFile);


+ 35
- 13
src/main/org/apache/tools/ant/types/FilterSet.java View File

@@ -176,8 +176,8 @@ public class FilterSet extends DataType {
/** The default token end string */ /** The default token end string */
public static final String DEFAULT_TOKEN_END = "@"; public static final String DEFAULT_TOKEN_END = "@";
private String startOftoken = DEFAULT_TOKEN_START;
private String endOftoken = DEFAULT_TOKEN_END;
private String startOfToken = DEFAULT_TOKEN_START;
private String endOfToken = DEFAULT_TOKEN_END;
/** /**
* List of ordered filters and filter files. * List of ordered filters and filter files.
@@ -245,9 +245,17 @@ public class FilterSet extends DataType {
if (isReference()) { if (isReference()) {
throw tooManyAttributes(); throw tooManyAttributes();
} }
startOftoken = startOfToken;
this.startOfToken = startOfToken;
}

public String getBeginToken() {
if (isReference()) {
return getRef().getBeginToken();
}
return startOfToken;
} }
/** /**
* The string used to id the end of a token. * The string used to id the end of a token.
* *
@@ -257,9 +265,17 @@ public class FilterSet extends DataType {
if (isReference()) { if (isReference()) {
throw tooManyAttributes(); throw tooManyAttributes();
} }
endOftoken = endOfToken;
this.endOfToken = endOfToken;
}

public String getEndToken() {
if (isReference()) {
return getRef().getEndToken();
}
return endOfToken;
} }
/** /**
* Read the filters from the given file. * Read the filters from the given file.
* *
@@ -268,6 +284,10 @@ public class FilterSet extends DataType {
* file. * file.
*/ */
public void readFiltersFromFile(File filtersFile) throws BuildException { public void readFiltersFromFile(File filtersFile) throws BuildException {
if (isReference()) {
throw tooManyAttributes();
}

if (filtersFile.isFile()) { if (filtersFile.isFile()) {
log("Reading filters from " + filtersFile, Project.MSG_VERBOSE ); log("Reading filters from " + filtersFile, Project.MSG_VERBOSE );
FileInputStream in = null; FileInputStream in = null;
@@ -310,7 +330,9 @@ public class FilterSet extends DataType {
* @return The string with the tokens replaced. * @return The string with the tokens replaced.
*/ */
public String replaceTokens(String line) { public String replaceTokens(String line) {
int index = line.indexOf(startOftoken);
String beginToken = getBeginToken();
String endToken = getEndToken();
int index = line.indexOf(beginToken);
if (index > -1) { if (index > -1) {
Hashtable tokens = getFilterHash(); Hashtable tokens = getFilterHash();
@@ -321,24 +343,24 @@ public class FilterSet extends DataType {
String value = null; String value = null;
do { do {
int endIndex = line.indexOf(endOftoken, index + startOftoken.length() + 1 );
int endIndex = line.indexOf(endToken, index + beginToken.length() + 1 );
if (endIndex == -1) { if (endIndex == -1) {
break; break;
} }
token = line.substring(index + startOftoken.length(), endIndex );
token = line.substring(index + beginToken.length(), endIndex );
b.append(line.substring(i, index)); b.append(line.substring(i, index));
if (tokens.containsKey(token)) { if (tokens.containsKey(token)) {
value = (String)tokens.get(token); value = (String)tokens.get(token);
log( "Replacing: " + startOftoken + token + endOftoken + " -> " + value, Project.MSG_VERBOSE );
log( "Replacing: " + beginToken + token + endToken + " -> " + value, Project.MSG_VERBOSE );
b.append(value); b.append(value);
i = index + startOftoken.length() + token.length() + endOftoken.length();
i = index + beginToken.length() + token.length() + endToken.length();
} }
else { else {
// just append startOftoken and search further
b.append(startOftoken);
i = index + startOftoken.length();
// just append beginToken and search further
b.append(beginToken);
i = index + beginToken.length();
} }
} while ((index = line.indexOf( startOftoken, i )) > -1 );
} while ((index = line.indexOf( beginToken, i )) > -1 );
b.append(line.substring(i)); b.append(line.substring(i));
return b.toString(); return b.toString();


+ 127
- 0
src/main/org/apache/tools/ant/types/FilterSetCollection.java View File

@@ -0,0 +1,127 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.tools.ant.types;

// java io classes
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

// java util classes
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Properties;
import java.util.Vector;

// ant classes
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;

/**
* A FilterSetCollection is a collection of filtersets each of which may have
* a different start/end token settings.
*
* @author <A href="mailto:conor@apache.org">Conor MacNeill</A>
*/
public class FilterSetCollection {
private Vector filterSets = new Vector();

public FilterSetCollection() {
}
public FilterSetCollection(FilterSet filterSet) {
addFilterSet(filterSet);
}
public void addFilterSet(FilterSet filterSet) {
filterSets.addElement(filterSet);
}
/**
* Does replacement on the given string with token matching.
* This uses the defined starttoken and endtoken values which default to @ for both.
*
* @param line The line to process the tokens in.
* @return The string with the tokens replaced.
*/
public String replaceTokens(String line) {
String replacedLine = line;
for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
FilterSet filterSet = (FilterSet)e.nextElement();
replacedLine = filterSet.replaceTokens(replacedLine);
}
return replacedLine;
}
/**
* Test to see if this filter set it empty.
*
* @return Return true if there are filter in this set otherwise false.
*/
public boolean hasFilters() {
for (Enumeration e = filterSets.elements(); e.hasMoreElements();) {
FilterSet filterSet = (FilterSet)e.nextElement();
if (filterSet.hasFilters()) {
return true;
}
}
return false;
}
}



+ 14
- 14
src/main/org/apache/tools/ant/util/FileUtils.java View File

@@ -61,7 +61,7 @@ import java.util.Stack;


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.types.FilterSet;
import org.apache.tools.ant.types.FilterSetCollection;


/** /**
* This class also encapsulates methods which allow Files to be * This class also encapsulates methods which allow Files to be
@@ -106,10 +106,10 @@ public class FileUtils {
* *
* @throws IOException * @throws IOException
*/ */
public void copyFile(String sourceFile, String destFile, FilterSet filterSet)
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters)
throws IOException throws IOException
{ {
copyFile(new File(sourceFile), new File(destFile), filterSet, false, false);
copyFile(new File(sourceFile), new File(destFile), filters, false, false);
} }


/** /**
@@ -119,9 +119,9 @@ public class FileUtils {
* *
* @throws IOException * @throws IOException
*/ */
public void copyFile(String sourceFile, String destFile, FilterSet filterSet,
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
boolean overwrite) throws IOException { boolean overwrite) throws IOException {
copyFile(new File(sourceFile), new File(destFile), filterSet,
copyFile(new File(sourceFile), new File(destFile), filters,
overwrite, false); overwrite, false);
} }


@@ -134,10 +134,10 @@ public class FileUtils {
* *
* @throws IOException * @throws IOException
*/ */
public void copyFile(String sourceFile, String destFile, FilterSet filterSet,
public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
boolean overwrite, boolean preserveLastModified) boolean overwrite, boolean preserveLastModified)
throws IOException { throws IOException {
copyFile(new File(sourceFile), new File(destFile), filterSet,
copyFile(new File(sourceFile), new File(destFile), filters,
overwrite, preserveLastModified); overwrite, preserveLastModified);
} }


@@ -157,9 +157,9 @@ public class FileUtils {
* *
* @throws IOException * @throws IOException
*/ */
public void copyFile(File sourceFile, File destFile, FilterSet filterSet)
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters)
throws IOException { throws IOException {
copyFile(sourceFile, destFile, filterSet, false, false);
copyFile(sourceFile, destFile, filters, false, false);
} }


/** /**
@@ -169,9 +169,9 @@ public class FileUtils {
* *
* @throws IOException * @throws IOException
*/ */
public void copyFile(File sourceFile, File destFile, FilterSet filterSet,
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
boolean overwrite) throws IOException { boolean overwrite) throws IOException {
copyFile(sourceFile, destFile, filterSet, overwrite, false);
copyFile(sourceFile, destFile, filters, overwrite, false);
} }


/** /**
@@ -183,7 +183,7 @@ public class FileUtils {
* *
* @throws IOException * @throws IOException
*/ */
public void copyFile(File sourceFile, File destFile, FilterSet filterSet,
public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
boolean overwrite, boolean preserveLastModified) boolean overwrite, boolean preserveLastModified)
throws IOException { throws IOException {
@@ -201,7 +201,7 @@ public class FileUtils {
parent.mkdirs(); parent.mkdirs();
} }


if (filterSet != null && filterSet.hasFilters()) {
if (filters != null && filters.hasFilters()) {
BufferedReader in = new BufferedReader(new FileReader(sourceFile)); BufferedReader in = new BufferedReader(new FileReader(sourceFile));
BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); BufferedWriter out = new BufferedWriter(new FileWriter(destFile));


@@ -212,7 +212,7 @@ public class FileUtils {
if (line.length() == 0) { if (line.length() == 0) {
out.newLine(); out.newLine();
} else { } else {
newline = filterSet.replaceTokens(line);
newline = filters.replaceTokens(line);
out.write(newline); out.write(newline);
out.newLine(); out.newLine();
} }


+ 128
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java View File

@@ -0,0 +1,128 @@
package org.apache.tools.ant.taskdefs.optional;

/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/

import junit.framework.TestCase;
import org.apache.tools.ant.taskdefs.XSLTLiaison;
import org.w3c.dom.Document;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import java.io.File;
import java.net.URL;

/**
* Abtract testcase for XSLTLiaison.
* Override createLiaison for each XSLTLiaison.
*
* <a href="sbailliez@apache.org">Stephane Bailliez</a>
*/
public abstract class AbstractXSLTLiaisonTest extends TestCase {

protected XSLTLiaison liaison;

protected AbstractXSLTLiaisonTest(String name){
super(name);
}

protected void setUp() throws Exception {
liaison = createLiaison();
}

// to override
protected abstract XSLTLiaison createLiaison() throws Exception ;

protected File getFile(String name){
URL url = getClass().getResource(name);
return new File(url.getFile());
}

/** keep it simple stupid */
public void testTransform() throws Exception {
File xsl = getFile("/taskdefs/optional/xsltliaison-in.xsl");
liaison.setStylesheet(xsl);
liaison.addParam("param", "value");
File in = getFile("/taskdefs/optional/xsltliaison-in.xml");
File out = new File("xsltliaison.tmp");
try {
liaison.transform(in, out);
} finally {
out.delete();
}
}

public void testEncoding() throws Exception {
File xsl = getFile("/taskdefs/optional/xsltliaison-encoding-in.xsl");
liaison.setStylesheet(xsl);
File in = getFile("/taskdefs/optional/xsltliaison-encoding-in.xml");
File out = new File("xsltliaison-encoding.tmp");
try {
liaison.transform(in, out);
Document doc = parseXML(out);
assertEquals("root",doc.getDocumentElement().getNodeName());
assertEquals("message",doc.getDocumentElement().getFirstChild().getNodeName());
assertEquals("\u00E9\u00E0\u00E8\u00EF\u00F9",doc.getDocumentElement().getFirstChild().getFirstChild().getNodeValue());
} finally {
out.delete();
}
}

public Document parseXML(File file) throws Exception {
DocumentBuilderFactory dbfactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dbuilder = dbfactory.newDocumentBuilder();
return dbuilder.parse(file);
}
}

+ 87
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java View File

@@ -0,0 +1,87 @@
package org.apache.tools.ant.taskdefs.optional;

import org.apache.tools.ant.taskdefs.XSLTLiaison;

import java.io.File;

/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/

/**
* TraX XSLTLiaison testcase
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
*/
public class TraXLiaisonTest extends AbstractXSLTLiaisonTest {
public TraXLiaisonTest(String name){
super(name);
}

public XSLTLiaison createLiaison() throws Exception {
return new TraXLiaison();
}

public void testXalan2Redirect() throws Exception {
File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
liaison.setStylesheet(xsl);
File out = new File("xalan2-redirect-out-dummy.tmp");
File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
try {
liaison.addParam("xalan-version", "2");
liaison.transform(in, out);
} finally {
out.delete();
}
}
}

+ 88
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java View File

@@ -0,0 +1,88 @@
package org.apache.tools.ant.taskdefs.optional;

/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/

import org.apache.tools.ant.taskdefs.XSLTLiaison;

import java.io.File;

/**
* Xalan Liaison testcase
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
*/
public class XalanLiaisonTest extends AbstractXSLTLiaisonTest {
public XalanLiaisonTest(String name){
super(name);
}

protected XSLTLiaison createLiaison() throws Exception {
return new XalanLiaison();
}

public void testXalan1Redirect() throws Exception {
File xsl = getFile("/taskdefs/optional/xalan-redirect-in.xsl");
liaison.setStylesheet(xsl);
File out = new File("xalan1-redirect-out-dummy.tmp");
File in = getFile("/taskdefs/optional/xsltliaison-in.xsl");
try {
liaison.addParam("xalan-version", "1");
liaison.transform(in, out);
} finally {
out.delete();
}
}
}


+ 72
- 0
src/testcases/org/apache/tools/ant/taskdefs/optional/XslpLiaisonTest.java View File

@@ -0,0 +1,72 @@
package org.apache.tools.ant.taskdefs.optional;

import org.apache.tools.ant.taskdefs.XSLTLiaison;

/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Jakarta-Regexp", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
*/

/**
* XSLP Liaison testcase
* @author <a href="mailto:sbailliez@apache.org">Stephane Bailliez</a>
*/
public class XslpLiaisonTest extends AbstractXSLTLiaisonTest {
public XslpLiaisonTest(String name){
super(name);
}

protected XSLTLiaison createLiaison() throws Exception {
return new XslpLiaison();
}
}

+ 144
- 0
src/testcases/org/apache/tools/ant/types/FilterSetTest.java View File

@@ -0,0 +1,144 @@
/*
* The Apache Software License, Version 1.1
*
* Copyright (c) 2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Ant", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/

package org.apache.tools.ant.types;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.TaskdefsTest;

import junit.framework.TestCase;
import junit.framework.AssertionFailedError;

import java.io.*;

/**
* FilterSet testing
*
* @author <a href="mailto:conor@apache.org">Conor MacNeill</a>
*/
public class FilterSetTest extends TaskdefsTest {

static private final int BUF_SIZE = 32768;
private Project project;

public FilterSetTest(String name) {
super(name);
}

public void setUp() {
configureProject("src/etc/testcases/types/filterset.xml");
}

public void test1() {
executeTarget("test1");
assertTrue("Filterset 1 failed", compareFiles("src/etc/testcases/types/gold/filterset1.txt",
"src/etc/testcases/types/dest1.txt"));
}

public void test2() {
executeTarget("test2");
assertTrue("Filterset 2 failed", compareFiles("src/etc/testcases/types/gold/filterset2.txt",
"src/etc/testcases/types/dest2.txt"));
}

public void test3() {
executeTarget("test3");
assertTrue("Filterset 3 failed", compareFiles("src/etc/testcases/types/gold/filterset3.txt",
"src/etc/testcases/types/dest3.txt"));
}

private boolean compareFiles(String name1, String name2) {
File file1 = new File(name1);
File file2 = new File(name2);
try {
if (!file1.exists() || !file2.exists()) {
System.out.println("One or both files do not exist:" + name1 + ", " + name2);
return false;
}
if (file1.length() != file2.length()) {
System.out.println("File size mismatch:" + name1 + "(" + file1.length() + "), " +
name2 + "(" + file2.length() + ")");
return false;
}
// byte - byte compare
byte[] buffer1 = new byte[BUF_SIZE];
byte[] buffer2 = new byte[BUF_SIZE];
FileInputStream fis1 = new FileInputStream(file1);
FileInputStream fis2 = new FileInputStream(file2);
int index = 0;
int read = 0;
while ((read = fis1.read(buffer1)) != -1) {
fis2.read(buffer2);
for (int i = 0; i < read; ++i, ++index) {
if (buffer1[i] != buffer2[i]) {
System.out.println("Bytes mismatch:" + name1 + ", " + name2 +
" at byte " + index);
return false;
}
}
}
return true;
}
catch (IOException e) {
System.out.println("IOException comparing files: " + name1 + ", " + name2);
return false;
}
}
}

+ 2
- 1
src/testcases/org/apache/tools/ant/util/FileUtilsTest.java View File

@@ -77,7 +77,8 @@ public class FileUtilsTest extends TestCase {


public void setUp() { public void setUp() {
fu = FileUtils.newFileUtils(); fu = FileUtils.newFileUtils();
root = new File(File.separator).getAbsolutePath();
// Windows adds the drive letter in uppercase, unless you run Cygnus
root = new File(File.separator).getAbsolutePath().toUpperCase();
} }


public void tearDown() { public void tearDown() {


Loading…
Cancel
Save