This is an automated email from the ASF dual-hosted git repository.
bodewig pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ant.git
The following commit(s) were added to refs/heads/master by this push:
new c45e66cd5 make documentation about symlinks agree with reality
c45e66cd5 is described below
commit c45e66cd5a1c8d42cb9b16f3e22bdc06374b0c35
Author: Stefan Bodewig <[email protected]>
AuthorDate: Sat Feb 7 19:04:01 2026 +0100
make documentation about symlinks agree with reality
---
WHATSNEW | 8 ++++++
manual/Tasks/image.html | 3 ++-
manual/Tasks/imageio.html | 3 ++-
manual/Types/dirset.html | 4 +--
manual/Types/fileset.html | 31 ++++++++++++++--------
manual/Types/multirootfileset.html | 4 +--
manual/Types/resources.html | 3 ++-
manual/Types/selectors.html | 15 ++++++-----
.../tools/ant/util/WindowsJunctionUtils.java | 1 +
9 files changed, 48 insertions(+), 24 deletions(-)
diff --git a/WHATSNEW b/WHATSNEW
index d9c4c79ac..dfd580f62 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -26,6 +26,14 @@ Changes that could break older environments:
checkServerIdentity.
Bugzilla Report 69416
+ * Ant now recognizes Windows junctions and treats them just like
+ symbolic links in general. With this builds on Windows that use
+ followSymlinks="false" and rely on Ant following Windowss junctions
+ will break. In order to get the old behavior you need to set
+ followSymlinks to true and exclude real symbolic links via the
+ <symlink> selector.
+ Bugzilla Report 66293
+
Fixed bugs:
-----------
diff --git a/manual/Tasks/image.html b/manual/Tasks/image.html
index 58b0bc0f3..ddbcc93fc 100644
--- a/manual/Tasks/image.html
+++ b/manual/Tasks/image.html
@@ -448,7 +448,8 @@ <h3>Parameters</h3>
</tr>
<tr>
<td>followSymlinks</td>
- <td>Boolean value. Sets whether or not symbolic links should be
followed.</td>
+ <td>Shall symbolic links and Windows junctions be followed? See <a
href="../Types/fileset.html#symlink">fileset's
+ documentation</a>. Windows junctions are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
</table>
diff --git a/manual/Tasks/imageio.html b/manual/Tasks/imageio.html
index 1010aa77a..08afd9498 100644
--- a/manual/Tasks/imageio.html
+++ b/manual/Tasks/imageio.html
@@ -450,7 +450,8 @@ <h3>Parameters</h3>
</tr>
<tr>
<td>followSymlinks</td>
- <td>Boolean value. Sets whether or not symbolic links should be
followed.</td>
+ <td>Shall symbolic links and Windows junctions be followed? See <a
href="../Types/fileset.html#symlink">fileset's
+ documentation</a>. Windows junctions are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
</table>
diff --git a/manual/Types/dirset.html b/manual/Types/dirset.html
index d391a1f63..f99844c34 100644
--- a/manual/Types/dirset.html
+++ b/manual/Types/dirset.html
@@ -77,8 +77,8 @@ <h2 id="dirset">DirSet</h2>
</tr>
<tr>
<td>followsymlinks</td>
- <td>Shall symbolic links be followed? See <a
href="fileset.html#symlink">fileset's
- documentation</a>.</td>
+ <td>Shall symbolic links and Windows junctions be followed? See <a
href="fileset.html#symlink">fileset's
+ documentation</a>. Windows junctions are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
<tr>
diff --git a/manual/Types/fileset.html b/manual/Types/fileset.html
index 62c2d1350..02fb5a3c9 100644
--- a/manual/Types/fileset.html
+++ b/manual/Types/fileset.html
@@ -87,7 +87,7 @@ <h2 id="fileset">FileSet</h2>
</tr>
<tr>
<td>followsymlinks</td>
- <td>Shall symbolic links be followed? See the note <a
href="#symlink">below</a>.</td>
+ <td>Shall symbolic links and Windows junctions be followed? See the note
<a href="#symlink">below</a>. Windows junctions are detected since Ant
1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
<tr>
@@ -109,19 +109,28 @@ <h2 id="fileset">FileSet</h2>
</tr>
</table>
-<p id="symlink"><strong>Note</strong>: All files/directories for which the
canonical path is
+<p id="symlink"><strong>Note</strong>: Prior to Ant 1.10.2 all
files/directories for which the canonical path is
different from its path are considered symbolic links. On Unix systems this
usually means the
file really is a symbolic link but it may lead to false results on other
platforms.</p>
-<p>Ant is restricted to features that JRE considers portable, and symbolic
links is one such feature
-that was long considered non-portable. That has changed with Java 7 and NIO.2,
yet full support for
-symbolic links is still lacking (notably, in Zip files). Full support of
symbolic links in Ant would
-require a different implementation of FileSet and revision of all tasks and/or
types that derive
-from it. Currently, the semantics of <var>followsymlinks</var> in FileSet is
such that <q>false</q>
-excludes symbolic links completely, and <q>true</q> allows symbolic links to
be considered by
-selectors, which may have their own <var>followsymlinks</var> attributes with
proper semantics;
-i.e., <q>false</q> allows selector to inspect properties of a symbolic link
itself, and <q>true</q>
-those of its target.
+<p>Starting with Ant 1.10.2 Ant relies
+ on <code><a
href="https://docs.oracle.com/javase/8/docs/api/java/nio/file/Files.html#isSymbolicLink-java.nio.file.Path-"
+ target="_blank">Files#isSymbolicLink</a></code> which is supposed to
+ work reliable on all platforms.</p>
+
+<p>Starting with Ant 1.10.16 Ant will also
+ detect <a
href="https://learn.microsoft.com/en-us/windows/win32/fileio/hard-links-and-junctions#junctions"
+ target="_blank">Windows junctions</a> and treat them just like
+ symbolic links in most cases.</p>
+
+<p>Full support for symbolic links is still lacking (notably, in Zip
+files). Currently, the semantics of <var>followsymlinks</var> in
+FileSet is such that <q>false</q> excludes symbolic links and Windows
+junctions completely, and <q>true</q> allows symbolic links and
+junctions to be considered by selectors, which may have their
+own <var>followsymlinks</var> attributes with proper semantics;
+i.e., <q>false</q> allows selector to inspect properties of a symbolic
+link or junction itself, and <q>true</q> those of its target.
</p>
<h4>Examples</h4>
diff --git a/manual/Types/multirootfileset.html
b/manual/Types/multirootfileset.html
index 51c50a453..b13773550 100644
--- a/manual/Types/multirootfileset.html
+++ b/manual/Types/multirootfileset.html
@@ -95,8 +95,8 @@ <h2 id="multirootfileset">MultiRootFileSet</h2>
</tr>
<tr>
<td>followsymlinks</td>
- <td>Shall symbolic links be followed? See <a
href="fileset.html#symlink">fileset's
- documentation</a>.</td>
+ <td>Shall symbolic links and Windows junctions be followed? See <a
href="fileset.html#symlink">fileset's
+ documentation</a>. Windows junctions are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
<tr>
diff --git a/manual/Types/resources.html b/manual/Types/resources.html
index 5783fd167..951df0558 100644
--- a/manual/Types/resources.html
+++ b/manual/Types/resources.html
@@ -570,7 +570,8 @@ <h4 id="files">files</h4>
</tr>
<tr id="followsymlinks">
<td>followsymlinks</td>
- <td>Whether to follow symbolic links (see note <a
href="#symlink">below</a>)</td>
+ <td>Shall symbolic links and Windows junctions be followed? See <a
href="fileset.html#symlink">fileset's
+ documentation</a>. Windows junctions are detected since Ant 1.10.16.</td>
<td>No; default <q>true</q></td>
</tr>
<tr>
diff --git a/manual/Types/selectors.html b/manual/Types/selectors.html
index 15552346f..31b4d3008 100644
--- a/manual/Types/selectors.html
+++ b/manual/Types/selectors.html
@@ -938,8 +938,9 @@ <h4 id="ownedBy">OwnedBy Selector</h4>
</tr>
<tr>
<td>followsymlinks</td>
- <td>Must the selector follow symbolic links? (see also how the
attribute interacts with the
- corresponding attribute of the <a
href="fileset.html#symlink">FileSet</a>)</td>
+ <td>Must the selector follow symbolic links and Windows junctions?
(see also how the attribute interacts with the
+ corresponding attribute of
+ the <a href="fileset.html#symlink">FileSet</a>). Windows junctions
are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
</table>
@@ -966,8 +967,9 @@ <h4 id="posixGroup">PosixGroup Selector</h4>
</tr>
<tr>
<td>followsymlinks</td>
- <td>Must the selector follow symbolic links? (see also how the
attribute interacts with the
- corresponding attribute of the <a
href="fileset.html#symlink">FileSet</a>)</td>
+ <td>Must the selector follow symbolic links and Windows junctions?
(see also how the attribute interacts with the
+ corresponding attribute of
+ the <a href="fileset.html#symlink">FileSet</a>). Windows junctions
are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
</table>
@@ -994,8 +996,9 @@ <h4 id="posixPermissions">PosixPermissions Selector</h4>
</tr>
<tr>
<td>followsymlinks</td>
- <td>Must the selector follow symbolic links? (see also how the
attribute interacts with
- the corresponding attribute of the <a
href="fileset.html#symlink">FileSet</a>)</td>
+ <td>Must the selector follow symbolic links and Windows junctions?
(see also how the attribute interacts with the
+ corresponding attribute of
+ the <a href="fileset.html#symlink">FileSet</a>). Windows junctions
are detected since Ant 1.10.16.</td>
<td>No; defaults to <q>true</q></td>
</tr>
</table>
diff --git a/src/main/org/apache/tools/ant/util/WindowsJunctionUtils.java
b/src/main/org/apache/tools/ant/util/WindowsJunctionUtils.java
index 4acde99f9..7bed9dadc 100644
--- a/src/main/org/apache/tools/ant/util/WindowsJunctionUtils.java
+++ b/src/main/org/apache/tools/ant/util/WindowsJunctionUtils.java
@@ -108,6 +108,7 @@ public class WindowsJunctionUtils {
if (!ON_WINDOWS) {
return false;
}
+ // see Alan Bateman's comment in
https://bugs.openjdk.org/browse/JDK-8031083
BasicFileAttributes attrs =
Files.readAttributes(path, BasicFileAttributes.class,
LinkOption.NOFOLLOW_LINKS);
return attrs.isDirectory() && attrs.isOther();