Browse Source

Change followlinks to followsymlinks for consistency with fileset

master
Gintas Grigelionis 7 years ago
parent
commit
cd1ce377dc
8 changed files with 24 additions and 24 deletions
  1. +3
    -3
      manual/Types/selectors.html
  2. +5
    -5
      src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java
  3. +5
    -5
      src/main/org/apache/tools/ant/types/selectors/PosixGroupSelector.java
  4. +5
    -5
      src/main/org/apache/tools/ant/types/selectors/PosixPermissionsSelector.java
  5. +3
    -3
      src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java
  6. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java
  7. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/selectors/PosixGroupSelectorTest.java
  8. +1
    -1
      src/tests/junit/org/apache/tools/ant/types/selectors/PosixPermissionsSelectorTest.java

+ 3
- 3
manual/Types/selectors.html View File

@@ -926,7 +926,7 @@
<td>Yes</td>
</tr>
<tr>
<td>followlinks</td>
<td>followsymlinks</td>
<td>Must the selector follow symbolic links?</td>
<td>No; defaults to <q>false</q> (was <q>true</q> before Ant 1.10.4)</td>
</tr>
@@ -953,7 +953,7 @@
<td>Yes</td>
</tr>
<tr>
<td>followlinks</td>
<td>followsymlinks</td>
<td>Must the selector follow symbolic links?</td>
<td>No; defaults to <q>false</q></td>
</tr>
@@ -980,7 +980,7 @@
<td>Yes</td>
</tr>
<tr>
<td>followlinks</td>
<td>followsymlinks</td>
<td>Must the selector follow symbolic links?</td>
<td>No; defaults to <q>false</q></td>
</tr>


+ 5
- 5
src/main/org/apache/tools/ant/types/selectors/OwnedBySelector.java View File

@@ -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) {


+ 5
- 5
src/main/org/apache/tools/ant/types/selectors/PosixGroupSelector.java View File

@@ -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);


+ 5
- 5
src/main/org/apache/tools/ant/types/selectors/PosixPermissionsSelector.java View File

@@ -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);


+ 3
- 3
src/tests/junit/org/apache/tools/ant/DirectoryScannerTest.java View File

@@ -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);



+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/selectors/OwnedBySelectorTest.java View File

@@ -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()));
}
}

+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/selectors/PosixGroupSelectorTest.java View File

@@ -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()));
}
}

+ 1
- 1
src/tests/junit/org/apache/tools/ant/types/selectors/PosixPermissionsSelectorTest.java View File

@@ -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()));
}
}


Loading…
Cancel
Save