You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pe...@apache.org on 2006/11/21 22:51:27 UTC

svn commit: r477913 - in /ant/core/trunk: WHATSNEW src/main/org/apache/tools/ant/types/ArchiveFileSet.java src/main/org/apache/tools/ant/types/TarFileSet.java src/main/org/apache/tools/ant/types/ZipFileSet.java

Author: peterreilly
Date: Tue Nov 21 13:51:26 2006
New Revision: 477913

URL: http://svn.apache.org/viewvc?view=rev&rev=477913
Log:
Fix for 41004: prefix with refid

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/TarFileSet.java
    ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=477913&r1=477912&r2=477913
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Tue Nov 21 13:51:26 2006
@@ -20,6 +20,9 @@
 * possible NPE in Jar.java.
   Bugzilla 40847
 
+* regression in attribute prefix (+ others) for refid in zipfileset and tarfileset.
+  Bugzilla 41004, 30498
+
 Other changes:
 --------------
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java?view=diff&rev=477913&r1=477912&r2=477913
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ArchiveFileSet.java Tue Nov 21 13:51:26 2006
@@ -130,7 +130,6 @@
      * @param srcFile The archive from which to extract entries.
      */
     public void setSrc(File srcFile) {
-        checkAttributesAllowed();
         setSrcResource(new FileResource(srcFile));
     }
 
@@ -141,7 +140,7 @@
      * @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 @@
      * @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 @@
      * @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 @@
      * @param octalString a <code>String</code> value
      */
     public void setFileMode(String octalString) {
-        checkAttributesAllowed();
+        checkArchiveAttributesAllowed();
         integerSetFileMode(Integer.parseInt(octalString, BASE_OCTAL));
     }
 
@@ -357,7 +356,7 @@
      * @param octalString a <code>String</code> value
      */
     public void setDirMode(String octalString) {
-        checkAttributesAllowed();
+        checkArchiveAttributesAllowed();
         integerSetDirMode(Integer.parseInt(octalString, BASE_OCTAL));
     }
 
@@ -477,4 +476,21 @@
         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();
+        }
+    }
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/TarFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/TarFileSet.java?view=diff&rev=477913&r1=477912&r2=477913
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/TarFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/TarFileSet.java Tue Nov 21 13:51:26 2006
@@ -68,7 +68,7 @@
      * @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 @@
      * @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 @@
      * @param groupName the group name string.
      */
     public void setGroup(String groupName) {
-        checkAttributesAllowed();
+        checkTarFileSetAttributesAllowed();
         groupNameSet = true;
         this.groupName = groupName;
     }
@@ -152,7 +152,7 @@
      * @param gid the group id.
      */
     public void setGid(int gid) {
-        checkAttributesAllowed();
+        checkTarFileSetAttributesAllowed();
         groupIdSet = true;
         this.gid = gid;
     }
@@ -248,4 +248,21 @@
             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();
+        }
+    }
+
 }

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java?view=diff&rev=477913&r1=477912&r2=477913
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/ZipFileSet.java Tue Nov 21 13:51:26 2006
@@ -63,7 +63,7 @@
      * @since Ant 1.7
      */
     public void setEncoding(String enc) {
-        checkAttributesAllowed();
+        checkZipFileSetAttributesAllowed();
         this.encoding = enc;
     }
 
@@ -127,4 +127,21 @@
             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();
+        }
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org