Browse Source

Fix for 41004: prefix with refid

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@477913 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 18 years ago
parent
commit
3095d02ef0
4 changed files with 64 additions and 11 deletions
  1. +3
    -0
      WHATSNEW
  2. +22
    -6
      src/main/org/apache/tools/ant/types/ArchiveFileSet.java
  3. +21
    -4
      src/main/org/apache/tools/ant/types/TarFileSet.java
  4. +18
    -1
      src/main/org/apache/tools/ant/types/ZipFileSet.java

+ 3
- 0
WHATSNEW View File

@@ -20,6 +20,9 @@ Fixed bugs:
* possible NPE in Jar.java.
Bugzilla 40847

* regression in attribute prefix (+ others) for refid in zipfileset and tarfileset.
Bugzilla 41004, 30498

Other changes:
--------------



+ 22
- 6
src/main/org/apache/tools/ant/types/ArchiveFileSet.java View File

@@ -130,7 +130,6 @@ public abstract class ArchiveFileSet extends FileSet {
* @param srcFile The archive from which to extract entries.
*/
public void setSrc(File srcFile) {
checkAttributesAllowed();
setSrcResource(new FileResource(srcFile));
}

@@ -141,7 +140,7 @@ public abstract class ArchiveFileSet extends FileSet {
* @param src The archive from which to extract entries.
*/
public void setSrcResource(Resource src) {
checkAttributesAllowed();
checkArchiveAttributesAllowed();
if (hasDir) {
throw new BuildException("Cannot set both dir and src attributes");
}
@@ -178,7 +177,7 @@ public abstract class ArchiveFileSet extends FileSet {
* @param prefix The prefix to prepend to entries in the archive file.
*/
public void setPrefix(String prefix) {
checkAttributesAllowed();
checkArchiveAttributesAllowed();
if (!prefix.equals("") && !fullpath.equals("")) {
throw new BuildException("Cannot set both fullpath and prefix attributes");
}
@@ -204,7 +203,7 @@ public abstract class ArchiveFileSet extends FileSet {
* @param fullpath the full pathname of the single entry in this fileset.
*/
public void setFullpath(String fullpath) {
checkAttributesAllowed();
checkArchiveAttributesAllowed();
if (!prefix.equals("") && !fullpath.equals("")) {
throw new BuildException("Cannot set both fullpath and prefix attributes");
}
@@ -308,7 +307,7 @@ public abstract class ArchiveFileSet extends FileSet {
* @param octalString a <code>String</code> value
*/
public void setFileMode(String octalString) {
checkAttributesAllowed();
checkArchiveAttributesAllowed();
integerSetFileMode(Integer.parseInt(octalString, BASE_OCTAL));
}

@@ -357,7 +356,7 @@ public abstract class ArchiveFileSet extends FileSet {
* @param octalString a <code>String</code> value
*/
public void setDirMode(String octalString) {
checkAttributesAllowed();
checkArchiveAttributesAllowed();
integerSetDirMode(Integer.parseInt(octalString, BASE_OCTAL));
}

@@ -477,4 +476,21 @@ public abstract class ArchiveFileSet extends FileSet {
return dirMode;
}

/**
* A check attributes for archiveFileSet.
* If there is a reference, and
* it is a ArchiveFileSet, the archive fileset attributes
* cannot be used.
* (Note, we can only see if the reference is an archive
* fileset if the project has been set).
*/
private void checkArchiveAttributesAllowed() {
if (getProject() == null
|| (isReference()
&& (getRefid().getReferencedObject(
getProject())
instanceof ArchiveFileSet))) {
checkAttributesAllowed();
}
}
}

+ 21
- 4
src/main/org/apache/tools/ant/types/TarFileSet.java View File

@@ -68,7 +68,7 @@ public class TarFileSet extends ArchiveFileSet {
* @param userName the user name for the tar entry.
*/
public void setUserName(String userName) {
checkAttributesAllowed();
checkTarFileSetAttributesAllowed();
userNameSet = true;
this.userName = userName;
}
@@ -96,7 +96,7 @@ public class TarFileSet extends ArchiveFileSet {
* @param uid the id of the user for the tar entry.
*/
public void setUid(int uid) {
checkAttributesAllowed();
checkTarFileSetAttributesAllowed();
userIdSet = true;
this.uid = uid;
}
@@ -124,7 +124,7 @@ public class TarFileSet extends ArchiveFileSet {
* @param groupName the group name string.
*/
public void setGroup(String groupName) {
checkAttributesAllowed();
checkTarFileSetAttributesAllowed();
groupNameSet = true;
this.groupName = groupName;
}
@@ -152,7 +152,7 @@ public class TarFileSet extends ArchiveFileSet {
* @param gid the group id.
*/
public void setGid(int gid) {
checkAttributesAllowed();
checkTarFileSetAttributesAllowed();
groupIdSet = true;
this.gid = gid;
}
@@ -248,4 +248,21 @@ public class TarFileSet extends ArchiveFileSet {
return super.clone();
}
}

/**
* A check attributes for TarFileSet.
* If there is a reference, and
* it is a TarFileSet, the tar fileset attributes
* cannot be used.
*/
private void checkTarFileSetAttributesAllowed() {
if (getProject() == null
|| (isReference()
&& (getRefid().getReferencedObject(
getProject())
instanceof TarFileSet))) {
checkAttributesAllowed();
}
}

}

+ 18
- 1
src/main/org/apache/tools/ant/types/ZipFileSet.java View File

@@ -63,7 +63,7 @@ public class ZipFileSet extends ArchiveFileSet {
* @since Ant 1.7
*/
public void setEncoding(String enc) {
checkAttributesAllowed();
checkZipFileSetAttributesAllowed();
this.encoding = enc;
}

@@ -127,4 +127,21 @@ public class ZipFileSet extends ArchiveFileSet {
return super.clone();
}
}

/**
* A check attributes for zipFileSet.
* If there is a reference, and
* it is a ZipFileSet, the zip fileset attributes
* cannot be used.
*/
private void checkZipFileSetAttributesAllowed() {
if (getProject() == null
|| (isReference()
&& (getRefid().getReferencedObject(
getProject())
instanceof ZipFileSet))) {
checkAttributesAllowed();
}
}

}

Loading…
Cancel
Save