From d2e4efab2a10e50699d44e5cc7e7ab9b0f49bebc Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 16 Feb 2022 12:51:36 -0600 Subject: [PATCH 1/6] propagate same properties as build.xml antunit invocation --- src/tests/antunit/antunit-base.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tests/antunit/antunit-base.xml b/src/tests/antunit/antunit-base.xml index 1336f2c0f..48226b8f6 100644 --- a/src/tests/antunit/antunit-base.xml +++ b/src/tests/antunit/antunit-base.xml @@ -51,6 +51,11 @@ + + + + + From b286069d212f1921d67b0c82c8f6f9f0d25b4539 Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 16 Feb 2022 12:52:22 -0600 Subject: [PATCH 2/6] skip tests relying on Javascript when running in Jenkins w/ JDK >= 15 --- .../types/optional/scriptcondition-test.xml | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/tests/antunit/types/optional/scriptcondition-test.xml b/src/tests/antunit/types/optional/scriptcondition-test.xml index 6a1b346b0..d136b0d73 100644 --- a/src/tests/antunit/types/optional/scriptcondition-test.xml +++ b/src/tests/antunit/types/optional/scriptcondition-test.xml @@ -18,13 +18,25 @@ - + + + + + + + + + + $${expect-js}=${expect-js} + + + - + self.setValue(true); @@ -32,7 +44,7 @@ - + self.setValue(false); @@ -40,19 +52,19 @@ - + - + - + self.setValue(true); @@ -60,7 +72,7 @@ - + self.setValue(false); @@ -68,7 +80,7 @@ - + true @@ -76,7 +88,7 @@ - + false From c9ed89099d29819a7e4358cf7c603a7415954299 Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 16 Feb 2022 12:57:32 -0600 Subject: [PATCH 3/6] remove spurious default field values --- .../apache/tools/ant/taskdefs/PathConvert.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java index be46bbdd2..b962f568d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java +++ b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java @@ -37,6 +37,7 @@ import org.apache.tools.ant.types.EnumeratedAttribute; import org.apache.tools.ant.types.Mapper; import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Reference; +import org.apache.tools.ant.types.Resource; import org.apache.tools.ant.types.ResourceCollection; import org.apache.tools.ant.types.resources.Resources; import org.apache.tools.ant.types.resources.Union; @@ -62,19 +63,19 @@ public class PathConvert extends Task { /** * Path to be converted */ - private Resources path = null; + private Resources path; /** * Reference to path/fileset to convert */ - private Reference refid = null; + private Reference refid; /** * The target OS type */ - private String targetOS = null; + private String targetOS; /** * Set when targetOS is set to windows */ - private boolean targetWindows = false; + private boolean targetWindows; /** * Set if we should create a new property even if the result is empty */ @@ -82,7 +83,7 @@ public class PathConvert extends Task { /** * The property to receive the conversion */ - private String property = null; + private String property; /** * Path prefix map */ @@ -90,14 +91,14 @@ public class PathConvert extends Task { /** * User override on path sep char */ - private String pathSep = null; + private String pathSep; /** * User override on directory sep char */ - private String dirSep = null; + private String dirSep; /** Filename mapper */ - private Mapper mapper = null; + private Mapper mapper; private boolean preserveDuplicates; From 0d0971ab8a53e412089e48b59fd12fe16ea0beb1 Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 16 Feb 2022 13:30:29 -0600 Subject: [PATCH 4/6] support writing pathconvert output to resource --- manual/Tasks/pathconvert.html | 12 +++++++-- .../tools/ant/taskdefs/PathConvert.java | 25 +++++++++++++++++-- .../antunit/taskdefs/pathconvert-test.xml | 20 +++++++++++++++ 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/manual/Tasks/pathconvert.html b/manual/Tasks/pathconvert.html index 4d1e5c3ef..3be11a6f3 100644 --- a/manual/Tasks/pathconvert.html +++ b/manual/Tasks/pathconvert.html @@ -28,7 +28,8 @@

Description

Converts nested resource collections, or a reference to just one, into a path form for a particular platform, optionally storing the result -into a given property. It can also be used when you need to convert a resource collection into a +into a property or writing to an Ant resource. +It can also be used when you need to convert a resource collection into a list, separated by a given character, such as a comma or space, or, conversely, e.g. to convert a list of files in a FileList into a path.

Nested <map> elements can be specified to map Windows drive letters to Unix @@ -65,7 +66,14 @@ nested <mapper> (since property The name of the property in which to place the converted path. - No, result will be logged if unset + No, result will be logged if neither @property nor @dest is set + + + dest + A destination resource into which to write the converted path (Ant interprets this as a + File by default). + + No, result will be logged if neither @property nor @dest is set refid diff --git a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java index b962f568d..cc7581de0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/PathConvert.java +++ b/src/main/org/apache/tools/ant/taskdefs/PathConvert.java @@ -102,6 +102,9 @@ public class PathConvert extends Task { private boolean preserveDuplicates; + /** Destination {@link Resource} */ + private Resource dest; + /** * Helper class, holds the nested <map> values. Elements will look like * this: <map from="d:" to="/foo"/> @@ -328,6 +331,19 @@ public class PathConvert extends Task { return refid != null; } + /** + * Set destination resource. + * @param dest + */ + public void setDest(Resource dest) { + if (dest != null) { + if (this.dest != null) { + throw new BuildException("@dest already set"); + } + } + this.dest = dest; + } + /** * Do the execution. * @throws BuildException if something is invalid. @@ -371,7 +387,10 @@ public class PathConvert extends Task { } } - private OutputStream createOutputStream() { + private OutputStream createOutputStream() throws IOException { + if (dest != null) { + return dest.getOutputStream(); + } if (property == null) { return new LogOutputStream(this); } @@ -452,10 +471,12 @@ public class PathConvert extends Task { * @throws BuildException if something is not set up properly. */ private void validateSetup() throws BuildException { - if (path == null) { throw new BuildException("You must specify a path to convert"); } + if (property != null && dest != null) { + throw new BuildException("@property and @dest are mutually exclusive"); + } // Determine the separator strings. The dirsep and pathsep attributes // override the targetOS settings. String dsep = File.separator; diff --git a/src/tests/antunit/taskdefs/pathconvert-test.xml b/src/tests/antunit/taskdefs/pathconvert-test.xml index d43eeac9f..b5d02014b 100644 --- a/src/tests/antunit/taskdefs/pathconvert-test.xml +++ b/src/tests/antunit/taskdefs/pathconvert-test.xml @@ -109,4 +109,24 @@ + + + + + + + + + + + + + + + + + + + + From 250d528ee35255bd4ac3219ff31b3014b9e0d6aa Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 16 Feb 2022 14:59:58 -0600 Subject: [PATCH 5/6] fixup testcase for Windows --- src/tests/antunit/taskdefs/pathconvert-test.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/antunit/taskdefs/pathconvert-test.xml b/src/tests/antunit/taskdefs/pathconvert-test.xml index b5d02014b..8a2f59836 100644 --- a/src/tests/antunit/taskdefs/pathconvert-test.xml +++ b/src/tests/antunit/taskdefs/pathconvert-test.xml @@ -117,7 +117,7 @@ - + From 0db467a379916a3d1fcf6956a0fedaf94cc25be3 Mon Sep 17 00:00:00 2001 From: Matt Benson Date: Wed, 16 Feb 2022 15:27:09 -0600 Subject: [PATCH 6/6] try again with a value that already handles dirsep --- src/tests/antunit/taskdefs/pathconvert-test.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/antunit/taskdefs/pathconvert-test.xml b/src/tests/antunit/taskdefs/pathconvert-test.xml index 8a2f59836..02ca11013 100644 --- a/src/tests/antunit/taskdefs/pathconvert-test.xml +++ b/src/tests/antunit/taskdefs/pathconvert-test.xml @@ -113,13 +113,13 @@ - + - +