- Note: failures are anticipated and checked for with assertions while errors are unanticipated.
+ Note: failures are anticipated and checked for with assertions while errors are unanticipated.
- Error
+ Error
+ FailureTableRowColor
@@ -558,7 +571,7 @@ H6 {
-
+
N/A
@@ -573,7 +586,7 @@ H6 {
-
+
@@ -606,6 +619,5 @@ H6 {
-
diff --git a/src/etc/testcases/taskdefs/optional/xalan-redirect-in.xsl b/src/etc/testcases/taskdefs/optional/xalan-redirect-in.xsl
new file mode 100644
index 000000000..2271b8177
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xalan-redirect-in.xsl
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+ This should be written to the file
+
+
+
+
\ No newline at end of file
diff --git a/src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xml b/src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xml
new file mode 100644
index 000000000..e95cd64ad
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xml
@@ -0,0 +1,4 @@
+
+
+ éàèïù
+
diff --git a/src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xsl b/src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xsl
new file mode 100644
index 000000000..0b4bc36d3
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xsltliaison-encoding-in.xsl
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/etc/testcases/taskdefs/optional/xsltliaison-in.xml b/src/etc/testcases/taskdefs/optional/xsltliaison-in.xml
new file mode 100644
index 000000000..fbab4566a
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xsltliaison-in.xml
@@ -0,0 +1,7 @@
+
+
+]>
+
+ &include;
+
diff --git a/src/etc/testcases/taskdefs/optional/xsltliaison-in.xsl b/src/etc/testcases/taskdefs/optional/xsltliaison-in.xsl
new file mode 100644
index 000000000..987de8881
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xsltliaison-in.xsl
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/etc/testcases/taskdefs/optional/xsltliaison-include.xml b/src/etc/testcases/taskdefs/optional/xsltliaison-include.xml
new file mode 100644
index 000000000..b92552241
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xsltliaison-include.xml
@@ -0,0 +1,2 @@
+
+
diff --git a/src/etc/testcases/taskdefs/optional/xsltliaison-include.xsl b/src/etc/testcases/taskdefs/optional/xsltliaison-include.xsl
new file mode 100644
index 000000000..10080948c
--- /dev/null
+++ b/src/etc/testcases/taskdefs/optional/xsltliaison-include.xsl
@@ -0,0 +1,3 @@
+
+
+
\ No newline at end of file
diff --git a/src/etc/testcases/types/filterset.xml b/src/etc/testcases/types/filterset.xml
new file mode 100644
index 000000000..77c3ecf0f
--- /dev/null
+++ b/src/etc/testcases/types/filterset.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/etc/testcases/types/filterseta.txt b/src/etc/testcases/types/filterseta.txt
new file mode 100644
index 000000000..440499503
--- /dev/null
+++ b/src/etc/testcases/types/filterseta.txt
@@ -0,0 +1,2 @@
+This is a test file for filters @aaaa@
+It has two lines @bbbb@
diff --git a/src/etc/testcases/types/filtersetb.txt b/src/etc/testcases/types/filtersetb.txt
new file mode 100644
index 000000000..f49640a38
--- /dev/null
+++ b/src/etc/testcases/types/filtersetb.txt
@@ -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
diff --git a/src/etc/testcases/types/filtersetc.txt b/src/etc/testcases/types/filtersetc.txt
new file mode 100644
index 000000000..2522d3500
--- /dev/null
+++ b/src/etc/testcases/types/filtersetc.txt
@@ -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
diff --git a/src/etc/testcases/types/gold/filterset1.txt b/src/etc/testcases/types/gold/filterset1.txt
new file mode 100644
index 000000000..975416f52
--- /dev/null
+++ b/src/etc/testcases/types/gold/filterset1.txt
@@ -0,0 +1,2 @@
+This is a test file for filters 1111
+It has two lines 2222
diff --git a/src/etc/testcases/types/gold/filterset2.txt b/src/etc/testcases/types/gold/filterset2.txt
new file mode 100644
index 000000000..eaab02156
--- /dev/null
+++ b/src/etc/testcases/types/gold/filterset2.txt
@@ -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
diff --git a/src/etc/testcases/types/gold/filterset3.txt b/src/etc/testcases/types/gold/filterset3.txt
new file mode 100644
index 000000000..3516e62b0
--- /dev/null
+++ b/src/etc/testcases/types/gold/filterset3.txt
@@ -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
diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java
index e12581b76..a5d0bc8b6 100644
--- a/src/main/org/apache/tools/ant/Main.java
+++ b/src/main/org/apache/tools/ant/Main.java
@@ -69,7 +69,6 @@ import java.util.*;
*
* @author duncan@x180.com
*/
-
public class Main {
/** The default build file name */
@@ -132,7 +131,7 @@ public class Main {
* Entry point allowing for more options from other front ends
*/
public static void start(String[] args, Properties additionalUserProperties,
- ClassLoader systemLoader) {
+ ClassLoader coreLoader) {
Main m = null;
try {
@@ -151,7 +150,7 @@ public class Main {
}
try {
- m.runBuild(systemLoader);
+ m.runBuild(coreLoader);
System.exit(0);
} catch (BuildException be) {
if (m.err != System.err) {
@@ -390,7 +389,7 @@ public class Main {
/**
* Executes the build.
*/
- private void runBuild(ClassLoader systemLoader) throws BuildException {
+ private void runBuild(ClassLoader coreLoader) throws BuildException {
if (!readyToRun) {
return;
@@ -403,7 +402,7 @@ public class Main {
}
final Project project = new Project();
- project.setSystemLoader(systemLoader);
+ project.setCoreLoader(coreLoader);
Throwable error = null;
@@ -433,15 +432,17 @@ public class Main {
// first use the ProjectHelper to create the project object
// from the given build file.
+ String noParserMessage =
+ "No JAXP compliant XML parser found. Please visit http://xml.apache.org for a suitable parser";
try {
Class.forName("javax.xml.parsers.SAXParserFactory");
ProjectHelper.configureProject(project, buildFile);
} 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) {
- 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) {
- 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
diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java
index 745a501ae..9636050e2 100644
--- a/src/main/org/apache/tools/ant/Project.java
+++ b/src/main/org/apache/tools/ant/Project.java
@@ -59,6 +59,7 @@ import java.util.*;
import java.text.*;
import org.apache.tools.ant.types.FilterSet;
+import org.apache.tools.ant.types.FilterSetCollection;
import org.apache.tools.ant.util.FileUtils;
/**
@@ -108,12 +109,13 @@ public class Project {
private Hashtable taskClassDefinitions = new Hashtable();
private Hashtable targets = new Hashtable();
private FilterSet globalFilterSet = new FilterSet();
+ private FilterSetCollection globalFilters = new FilterSetCollection(globalFilterSet);
private File baseDir;
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 */
private Hashtable threadTasks = new Hashtable();
@@ -216,12 +218,12 @@ public class Project {
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) {
@@ -671,7 +673,7 @@ public class Project {
*/
public void copyFile(String sourceFile, String destFile, boolean filtering)
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,
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,
boolean overwrite, boolean preserveLastModified)
throws IOException {
- fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null,
+ fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null,
overwrite, preserveLastModified);
}
@@ -728,7 +730,7 @@ public class Project {
*/
public void copyFile(File sourceFile, File destFile, boolean filtering)
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,
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,
boolean overwrite, boolean preserveLastModified)
throws IOException {
- fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilterSet : null,
+ fileUtils.copyFile(sourceFile, destFile, filtering ? globalFilters : null,
overwrite, preserveLastModified);
}
diff --git a/src/main/org/apache/tools/ant/listener/Log4jListener.java b/src/main/org/apache/tools/ant/listener/Log4jListener.java
index b93082ebb..263cd7fd0 100644
--- a/src/main/org/apache/tools/ant/listener/Log4jListener.java
+++ b/src/main/org/apache/tools/ant/listener/Log4jListener.java
@@ -73,7 +73,8 @@ public class Log4jListener implements BuildListener {
public Log4jListener() {
initialized = false;
Category cat = Category.getInstance("org.apache.tools.ant");
- if (!(cat.getAllAppenders() instanceof NullEnumeration)) {
+ Category rootCat = Category.getRoot();
+ if (!(rootCat.getAllAppenders() instanceof NullEnumeration)) {
initialized = true;
}
else {
@@ -90,7 +91,7 @@ public class Log4jListener implements BuildListener {
public void buildFinished(BuildEvent event) {
if (initialized) {
- Category cat = Category.getInstance(Target.class.getName());
+ Category cat = Category.getInstance(Project.class.getName());
if (event.getException() == null) {
cat.info("Build finished.");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Copy.java b/src/main/org/apache/tools/ant/taskdefs/Copy.java
index 28c962795..89c680b66 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Copy.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Copy.java
@@ -365,14 +365,14 @@ public class Copy extends Task {
try {
log("Copying " + fromFile + " to " + toFile, verbosity);
- FilterSet executionFilterSet = new FilterSet();
+ FilterSetCollection executionFilters = new FilterSetCollection();
if (filtering) {
- executionFilterSet.addFilterSet(project.getGlobalFilterSet());
+ executionFilters.addFilterSet(project.getGlobalFilterSet());
}
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);
} catch (IOException ioe) {
String msg = "Failed to copy " + fromFile + " to " + toFile
diff --git a/src/main/org/apache/tools/ant/taskdefs/DependSet.java b/src/main/org/apache/tools/ant/taskdefs/DependSet.java
index 35f8b0c11..215f585e5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/DependSet.java
+++ b/src/main/org/apache/tools/ant/taskdefs/DependSet.java
@@ -187,7 +187,7 @@ public class DependSet extends MatchingTask {
for (int i = 0; i < targetFiles.length; i++) {
File dest = new File(targetFS.getDir(project), targetFiles[i]);
- allTargets.add(dest);
+ allTargets.addElement(dest);
if (dest.lastModified() > now) {
log("Warning: "+targetFiles[i]+" modified in the future.",
@@ -215,7 +215,7 @@ public class DependSet extends MatchingTask {
continue;
}
else {
- allTargets.add(dest);
+ allTargets.addElement(dest);
}
if (dest.lastModified() > now) {
log("Warning: "+targetFiles[i]+" modified in the future.",
diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
index d3e9398a3..f94cdd8a3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
+++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java
@@ -114,7 +114,7 @@ public class ExecuteJava {
if (classpath == null) {
target = Class.forName(classname);
} else {
- loader = new AntClassLoader(project.getSystemLoader(), project, classpath, false);
+ loader = new AntClassLoader(project.getCoreLoader(), project, classpath, false);
loader.setIsolated(true);
loader.setThreadContextLoader();
target = loader.forceLoadClass(classname);
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index c60fa9102..2a8e48ff3 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -70,7 +70,9 @@ public class Jar extends Zip {
private File manifestFile;
private Manifest manifest;
- private Manifest execManifest;
+ private Manifest execManifest;
+
+ /** true if a manifest has been specified in the task */
private boolean buildFileManifest = false;
public Jar() {
@@ -279,15 +281,22 @@ public class Jar extends Zip {
theZipFile = new java.util.zip.ZipFile(zipFile);
java.util.zip.ZipEntry entry = theZipFile.getEntry("META-INF/MANIFEST.MF");
if (entry == null) {
+ log("Updating jar since the current jar has no manifest", Project.MSG_VERBOSE);
return false;
}
Manifest currentManifest = new Manifest(theZipFile.getInputStream(entry));
+ if (manifest == null) {
+ manifest = getDefaultManifest();
+ }
if (!currentManifest.equals(manifest)) {
+ log("Updating jar since jar manifest has changed", Project.MSG_VERBOSE);
return false;
}
}
catch (Exception e) {
// 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;
}
finally {
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java
index af0ac7db9..bb672a96d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javac.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java
@@ -115,6 +115,7 @@ public class Javac extends MatchingTask {
private boolean includeAntRuntime = true;
private boolean includeJavaRuntime = false;
private boolean fork = false;
+ private boolean nowarn = false;
protected boolean failOnError = true;
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.
*/
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index 64efe93de..1e6849640 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -681,9 +681,10 @@ public class Javadoc extends Task {
public String getPackages() {
StringBuffer p = new StringBuffer( "\"" );
for (int i = 0; i < packages.size(); i++) {
- p.append( packages.elementAt( i ).toString() );
- if ( i > 0 )
+ if ( i > 0 ) {
p.append( ":" );
+ }
+ p.append( packages.elementAt(i).toString() );
}
p.append( "\"" );
return p.toString();
diff --git a/src/main/org/apache/tools/ant/taskdefs/Move.java b/src/main/org/apache/tools/ant/taskdefs/Move.java
index bfe07fd74..a4f23a952 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Move.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Move.java
@@ -123,14 +123,14 @@ public class Move extends Copy {
try {
log("Moving " + fromFile + " to " + toFile, verbosity);
- FilterSet executionFilterSet = new FilterSet();
+ FilterSetCollection executionFilters = new FilterSetCollection();
if (filtering) {
- executionFilterSet.addFilterSet(project.getGlobalFilterSet());
+ executionFilters.addFilterSet(project.getGlobalFilterSet());
}
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);
f = new File(fromFile);
diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java b/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java
index c8c35eb9b..4325f4290 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java
@@ -54,19 +54,51 @@
package org.apache.tools.ant.taskdefs;
-import org.apache.tools.ant.*;
+import java.io.File;
/**
+ * Proxy interface for XSLT processors.
*
* @author Sam Ruby
- * @version $Revision$ $Date$
+ * @author Stephane Bailliez
+ * @see #XSLTProcess
*/
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: FILE_PROTOCOL_PREFIX + file.getAbsolutePath()
+ * 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 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
diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
index 9496c32e0..2f145825b 100644
--- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
+++ b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
@@ -100,9 +100,9 @@ public class XSLTProcess extends MatchingTask {
private String targetExtension = ".html";
private Vector params = new Vector();
-
+
private File inFile = null;
-
+
private File outFile = null;
private String processor;
@@ -137,7 +137,7 @@ public class XSLTProcess extends MatchingTask {
if (baseDir == null) {
baseDir = project.resolveFile(".");
}
-
+
liaison = getLiaison();
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) {
process( baseDir, list[i], destDir, stylesheet );
}
-
+
// Process all the directoried marked for styling
dirs = scanner.getIncludedDirectories();
for (int j = 0;j < dirs.length;++j){
@@ -264,15 +264,15 @@ public class XSLTProcess extends MatchingTask {
*/
private void resolveProcessor(String proc) throws Exception {
if (proc.equals("trax")) {
- final Class clazz =
+ final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.TraXLiaison");
liaison = (XSLTLiaison)clazz.newInstance();
} else if (proc.equals("xslp")) {
- final Class clazz =
+ final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.XslpLiaison");
liaison = (XSLTLiaison) clazz.newInstance();
} else if (proc.equals("xalan")) {
- final Class clazz =
+ final Class clazz =
loadClass("org.apache.tools.ant.taskdefs.optional.XalanLiaison");
liaison = (XSLTLiaison)clazz.newInstance();
} else {
@@ -313,14 +313,14 @@ public class XSLTProcess extends MatchingTask {
* Processes the given input XML file and stores the result
* in the given resultFile.
**/
- private void process(File baseDir, String xmlFile, File destDir,
+ private void process(File baseDir, String xmlFile, File destDir,
File stylesheet)
throws BuildException {
String fileExt=targetExtension;
File outFile=null;
File inFile=null;
-
+
try {
long styleSheetLastModified = stylesheet.lastModified();
inFile = new File(baseDir,xmlFile);
@@ -337,7 +337,7 @@ public class XSLTProcess extends MatchingTask {
log("Transforming into "+destDir);
configureLiaison(stylesheet);
- liaison.transform(inFile.toString(), outFile.toString());
+ liaison.transform(inFile, outFile);
}
}
catch (Exception ex) {
@@ -347,7 +347,7 @@ public class XSLTProcess extends MatchingTask {
if (outFile != null) {
outFile.delete();
}
-
+
throw new BuildException(ex);
}
@@ -365,7 +365,7 @@ public class XSLTProcess extends MatchingTask {
ensureDirectoryFor( outFile );
log("Processing " + inFile + " to " + outFile, Project.MSG_INFO);
configureLiaison(stylesheet);
- liaison.transform(inFile.toString(), outFile.toString());
+ liaison.transform(inFile, outFile);
}
}catch (Exception ex) {
log("Failed to process " + inFile, Project.MSG_INFO);
@@ -378,12 +378,12 @@ public class XSLTProcess extends MatchingTask {
File directory = new File( targetFile.getParent() );
if (!directory.exists()) {
if (!directory.mkdirs()) {
- throw new BuildException("Unable to create directory: "
+ throw new BuildException("Unable to create directory: "
+ directory.getAbsolutePath() );
}
}
}
-
+
protected XSLTLiaison getLiaison() {
// 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
@@ -424,20 +424,20 @@ public class XSLTProcess extends MatchingTask {
public class Param {
private String name=null;
private String expression=null;
-
+
public void setName(String name){
this.name = name;
}
-
+
public void setExpression(String expression){
this.expression = expression;
}
-
+
public String getName() throws BuildException{
if(name==null)throw new BuildException("Name attribute is missing.");
return name;
}
-
+
public String getExpression() throws BuildException{
if(expression==null)throw new BuildException("Expression attribute is missing.");
return expression;
@@ -455,7 +455,7 @@ public class XSLTProcess extends MatchingTask {
try {
log( "Loading stylesheet " + stylesheet, Project.MSG_INFO);
- liaison.setStylesheet( stylesheet.toString() );
+ liaison.setStylesheet( stylesheet );
for(Enumeration e = params.elements();e.hasMoreElements();) {
Param p = (Param)e.nextElement();
liaison.addParam( p.getName(), p.getExpression() );
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
index 708379eb5..2f5d2c9ab 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/DefaultCompilerAdapter.java
@@ -206,6 +206,10 @@ public abstract class DefaultCompilerAdapter implements CompilerAdapter {
protected Commandline setupJavacCommandlineSwitches(Commandline cmd) {
Path classpath = getCompileClasspath();
+ if (attributes.getNowarn()) {
+ cmd.createArgument().setValue("-nowarn");
+ }
+
if (deprecation == true) {
cmd.createArgument().setValue("-deprecation");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
index fbc4e1266..fc5b39a92 100644
--- a/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
+++ b/src/main/org/apache/tools/ant/taskdefs/compilers/Jikes.java
@@ -173,7 +173,21 @@ public class Jikes extends DefaultCompilerAdapter {
* warning can be pretty annoying.
*/
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");
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties
index c318b0230..acd605588 100644
--- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties
+++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties
@@ -113,8 +113,8 @@ vsscheckout=org.apache.tools.ant.taskdefs.optional.vss.MSVSSCHECKOUT
iplanet-ejbc=org.apache.tools.ant.taskdefs.optional.ejb.IPlanetEjbcTask
jdepend=org.apache.tools.ant.taskdefs.optional.jdepend.JDependTask
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
ccmreconfigure=org.apache.tools.ant.taskdefs.optional.ccm.CCMReconfigure
ccmcreatetask=org.apache.tools.ant.taskdefs.optional.ccm.CCMCreateTask
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
index 38f5973df..565d8d5a1 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/TraXLiaison.java
@@ -54,61 +54,109 @@
package org.apache.tools.ant.taskdefs.optional;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.IOException;
import org.apache.tools.ant.taskdefs.XSLTLiaison;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Templates;
+import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
/**
+ * Concrete liaison for XSLT processor implementing TraX. (ie JAXP 1.1)
*
* @author Sam Ruby
* @author Davanum Srinivas
- * @version $Revision$ $Date$
+ * @author Stephane Bailliez
*/
public class TraXLiaison implements XSLTLiaison {
- protected final static String FILEURL = "file:";
-
/** The trax TransformerFactory */
private TransformerFactory tfactory = null;
+ /** stylesheet stream, close it asap */
+ private FileInputStream xslStream = null;
+
/** Stylesheet template */
private Templates templates = null;
- /** The trax Transformer itself */
- private Transformer transformer;
+ /** transformer */
+ private Transformer transformer = null;
public TraXLiaison() throws Exception {
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();
- };
+ }
- 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 {
- 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 {
- 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){
transformer.setParameter(name, value);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java
index e3a805d8a..b5d944368 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java
@@ -60,39 +60,70 @@ import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTProcessor;
import org.apache.xalan.xslt.XSLTInputSource;
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 Sam Ruby
- * @version $Revision$ $Date$
+ * @author Stephane Bailliez
*/
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 {
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){
processor.setStylesheetParam(name, value);
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java
index 7ec791ee0..7176819cb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java
@@ -54,40 +54,45 @@
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.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 Sam Ruby
- * @version $Revision$ $Date$
+ * @author Stephane Bailliez
*/
public class XslpLiaison implements XSLTLiaison {
- XSLProcessor processor;
- XSLStylesheet xslSheet;
+ protected XSLProcessor processor;
+ protected XSLStylesheet xslSheet;
public XslpLiaison() {
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();
- 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){
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
index 70fc4ea14..c86589e5c 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/depend/Depend.java
@@ -137,6 +137,12 @@ public class Depend extends MatchingTask {
/** The classpath to look for additional dependencies */
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.
*/
@@ -169,46 +175,74 @@ public class Depend extends MatchingTask {
public void setClasspathRef(Reference 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 {
affectedClassMap = 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(); ) {
ClassFileInfo info = (ClassFileInfo)e.nextElement();
log("Adding class info for " + info.className, Project.MSG_DEBUG);
@@ -230,12 +277,11 @@ public class Depend extends MatchingTask {
Vector dependencyList = 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
- // 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);
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 {
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
// one of those, add this class into their affected classes list
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() {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
index ed43acee2..ea8df9a6f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
@@ -87,6 +87,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
* Bunch of constants used for storing entries in a hashtable, and for
* 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 REMOTE_INTERFACE = "remote";
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 boolean inEJBRef = false;
+
private Hashtable urlDTDs = new Hashtable();
/**
@@ -244,6 +247,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
public void startDocument() throws SAXException {
this.ejbFiles = new Hashtable(10, 1);
this.currentElement = null;
+ inEJBRef = false;
}
@@ -258,7 +262,10 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
throws SAXException {
this.currentElement = name;
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;
}
else if (parseState == STATE_IN_EJBJAR && name.equals(ENTERPRISE_BEANS)) {
@@ -286,7 +293,10 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase {
processElement();
currentText = "";
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;
}
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() {
- if (parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION) {
+ if (inEJBRef ||
+ (parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION)) {
return;
}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java
index 75779d09e..39077da14 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java
@@ -263,12 +263,11 @@ public class WLRun extends Task {
File propertiesFile = 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()) {
// OK, properties file may be absolute
propertiesFile = project.resolveFile(weblogicPropertiesFile);
diff --git a/src/main/org/apache/tools/ant/types/FilterSet.java b/src/main/org/apache/tools/ant/types/FilterSet.java
index 67ff8d8c0..9b87db7f8 100644
--- a/src/main/org/apache/tools/ant/types/FilterSet.java
+++ b/src/main/org/apache/tools/ant/types/FilterSet.java
@@ -176,8 +176,8 @@ public class FilterSet extends DataType {
/** The default token end string */
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.
@@ -245,9 +245,17 @@ public class FilterSet extends DataType {
if (isReference()) {
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.
*
@@ -257,9 +265,17 @@ public class FilterSet extends DataType {
if (isReference()) {
throw tooManyAttributes();
}
- endOftoken = endOfToken;
+ this.endOfToken = endOfToken;
+ }
+
+ public String getEndToken() {
+ if (isReference()) {
+ return getRef().getEndToken();
+ }
+ return endOfToken;
}
+
/**
* Read the filters from the given file.
*
@@ -268,6 +284,10 @@ public class FilterSet extends DataType {
* file.
*/
public void readFiltersFromFile(File filtersFile) throws BuildException {
+ if (isReference()) {
+ throw tooManyAttributes();
+ }
+
if (filtersFile.isFile()) {
log("Reading filters from " + filtersFile, Project.MSG_VERBOSE );
FileInputStream in = null;
@@ -310,7 +330,9 @@ public class FilterSet extends DataType {
* @return The string with the tokens replaced.
*/
public String replaceTokens(String line) {
- int index = line.indexOf(startOftoken);
+ String beginToken = getBeginToken();
+ String endToken = getEndToken();
+ int index = line.indexOf(beginToken);
if (index > -1) {
Hashtable tokens = getFilterHash();
@@ -321,24 +343,24 @@ public class FilterSet extends DataType {
String value = null;
do {
- int endIndex = line.indexOf(endOftoken, index + startOftoken.length() + 1 );
+ int endIndex = line.indexOf(endToken, index + beginToken.length() + 1 );
if (endIndex == -1) {
break;
}
- token = line.substring(index + startOftoken.length(), endIndex );
+ token = line.substring(index + beginToken.length(), endIndex );
b.append(line.substring(i, index));
if (tokens.containsKey(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);
- i = index + startOftoken.length() + token.length() + endOftoken.length();
+ i = index + beginToken.length() + token.length() + endToken.length();
}
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));
return b.toString();
diff --git a/src/main/org/apache/tools/ant/types/FilterSetCollection.java b/src/main/org/apache/tools/ant/types/FilterSetCollection.java
new file mode 100644
index 000000000..6568bf00d
--- /dev/null
+++ b/src/main/org/apache/tools/ant/types/FilterSetCollection.java
@@ -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
+ * .
+ */
+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 Conor MacNeill
+ */
+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;
+ }
+}
+
+
+
diff --git a/src/main/org/apache/tools/ant/util/FileUtils.java b/src/main/org/apache/tools/ant/util/FileUtils.java
index 03d3b9691..3e01bda5c 100644
--- a/src/main/org/apache/tools/ant/util/FileUtils.java
+++ b/src/main/org/apache/tools/ant/util/FileUtils.java
@@ -61,7 +61,7 @@ import java.util.Stack;
import org.apache.tools.ant.BuildException;
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
@@ -106,10 +106,10 @@ public class FileUtils {
*
* @throws IOException
*/
- public void copyFile(String sourceFile, String destFile, FilterSet filterSet)
+ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters)
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
*/
- public void copyFile(String sourceFile, String destFile, FilterSet filterSet,
+ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
boolean overwrite) throws IOException {
- copyFile(new File(sourceFile), new File(destFile), filterSet,
+ copyFile(new File(sourceFile), new File(destFile), filters,
overwrite, false);
}
@@ -134,10 +134,10 @@ public class FileUtils {
*
* @throws IOException
*/
- public void copyFile(String sourceFile, String destFile, FilterSet filterSet,
+ public void copyFile(String sourceFile, String destFile, FilterSetCollection filters,
boolean overwrite, boolean preserveLastModified)
throws IOException {
- copyFile(new File(sourceFile), new File(destFile), filterSet,
+ copyFile(new File(sourceFile), new File(destFile), filters,
overwrite, preserveLastModified);
}
@@ -157,9 +157,9 @@ public class FileUtils {
*
* @throws IOException
*/
- public void copyFile(File sourceFile, File destFile, FilterSet filterSet)
+ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters)
throws IOException {
- copyFile(sourceFile, destFile, filterSet, false, false);
+ copyFile(sourceFile, destFile, filters, false, false);
}
/**
@@ -169,9 +169,9 @@ public class FileUtils {
*
* @throws IOException
*/
- public void copyFile(File sourceFile, File destFile, FilterSet filterSet,
+ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
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
*/
- public void copyFile(File sourceFile, File destFile, FilterSet filterSet,
+ public void copyFile(File sourceFile, File destFile, FilterSetCollection filters,
boolean overwrite, boolean preserveLastModified)
throws IOException {
@@ -201,7 +201,7 @@ public class FileUtils {
parent.mkdirs();
}
- if (filterSet != null && filterSet.hasFilters()) {
+ if (filters != null && filters.hasFilters()) {
BufferedReader in = new BufferedReader(new FileReader(sourceFile));
BufferedWriter out = new BufferedWriter(new FileWriter(destFile));
@@ -212,7 +212,7 @@ public class FileUtils {
if (line.length() == 0) {
out.newLine();
} else {
- newline = filterSet.replaceTokens(line);
+ newline = filters.replaceTokens(line);
out.write(newline);
out.newLine();
}
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java
new file mode 100644
index 000000000..394e7560f
--- /dev/null
+++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/AbstractXSLTLiaisonTest.java
@@ -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
+ * .
+ *
+ */
+
+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.
+ *
+ * Stephane Bailliez
+ */
+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);
+ }
+}
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
new file mode 100644
index 000000000..0e63e64ae
--- /dev/null
+++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/TraXLiaisonTest.java
@@ -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
+ * .
+ *
+ */
+
+/**
+ * TraX XSLTLiaison testcase
+ * @author Stephane Bailliez
+ */
+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();
+ }
+ }
+}
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java
new file mode 100644
index 000000000..4aa4c13af
--- /dev/null
+++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/XalanLiaisonTest.java
@@ -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
+ * .
+ *
+ */
+
+import org.apache.tools.ant.taskdefs.XSLTLiaison;
+
+import java.io.File;
+
+/**
+ * Xalan Liaison testcase
+ * @author Stephane Bailliez
+ */
+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();
+ }
+ }
+}
+
diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/XslpLiaisonTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/XslpLiaisonTest.java
new file mode 100644
index 000000000..fb6a771d7
--- /dev/null
+++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/XslpLiaisonTest.java
@@ -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
+ * .
+ *
+ */
+
+/**
+ * XSLP Liaison testcase
+ * @author Stephane Bailliez
+ */
+public class XslpLiaisonTest extends AbstractXSLTLiaisonTest {
+ public XslpLiaisonTest(String name){
+ super(name);
+ }
+
+ protected XSLTLiaison createLiaison() throws Exception {
+ return new XslpLiaison();
+ }
+}
diff --git a/src/testcases/org/apache/tools/ant/types/FilterSetTest.java b/src/testcases/org/apache/tools/ant/types/FilterSetTest.java
new file mode 100644
index 000000000..41bc12dd3
--- /dev/null
+++ b/src/testcases/org/apache/tools/ant/types/FilterSetTest.java
@@ -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
+ * .
+ */
+
+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 Conor MacNeill
+ */
+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;
+ }
+ }
+}
diff --git a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java
index cdceb38e9..a33699f23 100644
--- a/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java
+++ b/src/testcases/org/apache/tools/ant/util/FileUtilsTest.java
@@ -77,7 +77,8 @@ public class FileUtilsTest extends TestCase {
public void setUp() {
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() {