From cd1ce377dc769671b46ca6e68adb604b0453b4a3 Mon Sep 17 00:00:00 2001 From: Gintas Grigelionis Date: Wed, 23 May 2018 19:09:18 +0200 Subject: [PATCH] Change followlinks to followsymlinks for consistency with fileset --- manual/Types/selectors.html | 6 +++--- .../tools/ant/types/selectors/OwnedBySelector.java | 10 +++++----- .../tools/ant/types/selectors/PosixGroupSelector.java | 10 +++++----- .../ant/types/selectors/PosixPermissionsSelector.java | 10 +++++----- .../org/apache/tools/ant/DirectoryScannerTest.java | 6 +++--- .../tools/ant/types/selectors/OwnedBySelectorTest.java | 2 +- .../ant/types/selectors/PosixGroupSelectorTest.java | 2 +- .../types/selectors/PosixPermissionsSelectorTest.java | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/manual/Types/selectors.html b/manual/Types/selectors.html index 9265298f2..e3d11b8ba 100644 --- a/manual/Types/selectors.html +++ b/manual/Types/selectors.html @@ -926,7 +926,7 @@ Yes - followlinks + followsymlinks Must the selector follow symbolic links? No; defaults to false (was true before Ant 1.10.4) @@ -953,7 +953,7 @@ Yes - followlinks + followsymlinks Must the selector follow symbolic links? No; defaults to false @@ -980,7 +980,7 @@ Yes - followlinks + followsymlinks Must the selector follow symbolic links? No; defaults to false diff --git a/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java b/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java index cb21de485..f9c593bdd 100644 --- a/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java @@ -42,7 +42,7 @@ public class OwnedBySelector implements FileSelector { private String owner; - private boolean followLinks = false; + private boolean followSymlinks = false; /** * Sets the user name to look for. @@ -54,10 +54,10 @@ public class OwnedBySelector implements FileSelector { /** * Sets the "follow links" flag. - * @param followLinks the user name + * @param followSymlinks the user name */ - public void setFollowLinks(String followLinks) { - this.followLinks = PropertyHelper.toBoolean(followLinks); + public void setFollowSymlinks(String followSymlinks) { + this.followSymlinks = PropertyHelper.toBoolean(followSymlinks); } @Override @@ -67,7 +67,7 @@ public class OwnedBySelector implements FileSelector { } if (file != null) { try { - UserPrincipal user = followLinks ? Files.getOwner(file.toPath()) + UserPrincipal user = followSymlinks ? Files.getOwner(file.toPath()) : Files.getOwner(file.toPath(), LinkOption.NOFOLLOW_LINKS); return user != null && owner.equals(user.getName()); } catch (UnsupportedOperationException | IOException ex) { diff --git a/src/main/org/apache/tools/ant/types/selectors/PosixGroupSelector.java b/src/main/org/apache/tools/ant/types/selectors/PosixGroupSelector.java index a72d0fd15..4dfa7ec7c 100644 --- a/src/main/org/apache/tools/ant/types/selectors/PosixGroupSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/PosixGroupSelector.java @@ -42,7 +42,7 @@ public class PosixGroupSelector implements FileSelector { private String group; - private boolean followLinks = false; + private boolean followSymlinks = false; /** * Sets the group name to look for. @@ -54,10 +54,10 @@ public class PosixGroupSelector implements FileSelector { /** * Sets the "follow links" flag. - * @param followLinks the user name + * @param followSymlinks the user name */ - public void setFollowLinks(String followLinks) { - this.followLinks = PropertyHelper.toBoolean(followLinks); + public void setFollowSymlinks(String followSyminks) { + this.followSymlinks = PropertyHelper.toBoolean(followSymlinks); } @Override @@ -66,7 +66,7 @@ public class PosixGroupSelector implements FileSelector { throw new BuildException("the group attribute is required"); } try { - GroupPrincipal actualGroup = followLinks ? Files.readAttributes(file.toPath(), + GroupPrincipal actualGroup = followSymlinks ? Files.readAttributes(file.toPath(), PosixFileAttributes.class).group() : Files.readAttributes(file.toPath(), PosixFileAttributes.class, LinkOption.NOFOLLOW_LINKS).group(); return actualGroup != null && actualGroup.getName().equals(group); diff --git a/src/main/org/apache/tools/ant/types/selectors/PosixPermissionsSelector.java b/src/main/org/apache/tools/ant/types/selectors/PosixPermissionsSelector.java index fd6cef71b..bc872ed5f 100644 --- a/src/main/org/apache/tools/ant/types/selectors/PosixPermissionsSelector.java +++ b/src/main/org/apache/tools/ant/types/selectors/PosixPermissionsSelector.java @@ -41,7 +41,7 @@ public class PosixPermissionsSelector implements FileSelector { private String permissions; - private boolean followLinks = false; + private boolean followSymlinks = false; /** * Sets the permissions to look for. @@ -64,10 +64,10 @@ public class PosixPermissionsSelector implements FileSelector { /** * Sets the "follow links" flag. - * @param followLinks the user name + * @param followSymlinks the user name */ - public void setFollowLinks(String followLinks) { - this.followLinks = PropertyHelper.toBoolean(followLinks); + public void setFollowSymlinks(String followSymlinks) { + this.followSymlinks = PropertyHelper.toBoolean(followSymlinks); } @Override @@ -76,7 +76,7 @@ public class PosixPermissionsSelector implements FileSelector { throw new BuildException("the permissions attribute is required"); } try { - return PosixFilePermissions.toString(followLinks + return PosixFilePermissions.toString(followSymlinks ? Files.getPosixFilePermissions(file.toPath()) : Files.getPosixFilePermissions(file.toPath(), LinkOption.NOFOLLOW_LINKS)) .equals(permissions); diff --git a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java index f7874ef39..6dab26c11 100644 --- a/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java +++ b/src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java @@ -217,14 +217,14 @@ public class DirectoryScannerTest { } /** - * Test case for setFollowLinks() and associated functionality. + * Test case for setFollowSymlinks() and associated functionality. * Only supports test on Linux at the moment because Java has * no real notion of symlinks built in, so an os-specfic call * to Runtime.exec() must be made to create a link to test against. * @throws InterruptedException if something goes wrong */ @Test - public void testSetFollowLinks() throws IOException, InterruptedException { + public void testSetFollowSymlinks() throws IOException, InterruptedException { if (supportsSymlinks) { File dir = new File(buildRule.getProject().getBaseDir(), "../../../main/org/apache/tools"); @@ -240,7 +240,7 @@ public class DirectoryScannerTest { Process process = Runtime.getRuntime().exec(command); assertEquals("0 return code expected for external process", 0, process.waitFor()); - // followLinks should be true by default, but if this ever + // followSymlinks should be true by default, but if this ever // changes we will need this line. ds.setFollowSymlinks(true); diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java index e8619e4ed..77b31ddfa 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java @@ -80,7 +80,7 @@ public class OwnedBySelectorTest { s.setOwner(SELF); assertTrue(s.isSelected(null, null, symbolicLink.toFile())); - s.setFollowLinks("yes"); + s.setFollowSymlinks("yes"); assertFalse(s.isSelected(null, null, symbolicLink.toFile())); } } diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/PosixGroupSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/PosixGroupSelectorTest.java index 2cb0a213a..f9a9d622c 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/PosixGroupSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/PosixGroupSelectorTest.java @@ -87,7 +87,7 @@ public class PosixGroupSelectorTest { s.setGroup(linkGroup.getName()); assertTrue(s.isSelected(null, null, symbolicLink.toFile())); - s.setFollowLinks("yes"); + s.setFollowSymlinks("yes"); assertFalse(s.isSelected(null, null, symbolicLink.toFile())); } } diff --git a/src/tests/junit/org/apache/tools/ant/types/selectors/PosixPermissionsSelectorTest.java b/src/tests/junit/org/apache/tools/ant/types/selectors/PosixPermissionsSelectorTest.java index 1dde9c482..9aff3b5e4 100644 --- a/src/tests/junit/org/apache/tools/ant/types/selectors/PosixPermissionsSelectorTest.java +++ b/src/tests/junit/org/apache/tools/ant/types/selectors/PosixPermissionsSelectorTest.java @@ -125,7 +125,7 @@ public class PosixPermissionsSelectorTest { s.setPermissions(argument); assertFalse(s.isSelected(null, null, symbolicLink.toFile())); - s.setFollowLinks("yes"); + s.setFollowSymlinks("yes"); assertTrue(s.isSelected(null, null, symbolicLink.toFile())); } }