ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r1150544 - in /ant/antlibs/compress/trunk/src/main/org/apache/ant/compress: resources/CommonsCompressArchiveScanner.java resources/ZipScanner.java taskdefs/ExpandBase.java taskdefs/Unzip.java util/Messages.java
Date Mon, 25 Jul 2011 04:45:01 GMT
Author: bodewig
Date: Mon Jul 25 04:45:00 2011
New Revision: 1150544

URL: http://svn.apache.org/viewvc?rev=1150544&view=rev
Log:
factor out common message

Added:
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Messages.java   (with
props)
Modified:
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java
    ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Unzip.java

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java?rev=1150544&r1=1150543&r2=1150544&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
(original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/CommonsCompressArchiveScanner.java
Mon Jul 25 04:45:00 2011
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.util.Map;
 
 import org.apache.ant.compress.util.ArchiveStreamFactory;
+import org.apache.ant.compress.util.Messages;
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.ArchiveScanner;
@@ -66,13 +67,6 @@ public class CommonsCompressArchiveScann
     }
 
     /**
-     * @since Compress Antlib 1.1
-     */
-    public Project getProject() {
-        return project;
-    }
-
-    /**
      * Fills the file and directory maps with resources read from the
      * archive.
      *
@@ -106,8 +100,7 @@ public class CommonsCompressArchiveScann
             }
             while ((entry = ai.getNextEntry()) != null) {
                 if (skipUnreadable && !ai.canReadEntryData(entry)) {
-                    project.log("skipping " + entry.getName()
-                                + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(entry));
                     continue;
                 }
                 Resource r = builder.buildResource(src, encoding, entry);
@@ -132,6 +125,18 @@ public class CommonsCompressArchiveScann
         }
     }
 
+    /**
+     * @since Compress Antlib 1.1
+     */
+    protected final void log(String msg) {
+        if (project != null) {
+            project.log(msg);
+        } else {
+            // rely on Ant's output redirection
+            System.out.println(msg);
+        }
+    }
+
     public static interface ResourceBuilder {
         /**
          * Creates the matching archive entry resource.

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java?rev=1150544&r1=1150543&r2=1150544&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
(original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/resources/ZipScanner.java
Mon Jul 25 04:45:00 2011
@@ -27,6 +27,7 @@ import java.util.zip.ZipException;
 import org.apache.ant.compress.util.ZipStreamFactory;
 
 import org.apache.commons.compress.archivers.ArchiveEntry;
+import org.apache.ant.compress.util.Messages;
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
 import org.apache.commons.compress.archivers.zip.ZipFile;
 import org.apache.tools.ant.BuildException;
@@ -99,8 +100,7 @@ public class ZipScanner extends CommonsC
             while (e.hasMoreElements()) {
                 entry = (ZipArchiveEntry) e.nextElement();
                 if (getSkipUnreadableEntries() && !zf.canReadEntryData(entry)) {
-                    getProject().log("skipping " + entry.getName()
-                                     + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(entry));
                     continue;
                 }
                 Resource r = new ZipResource(srcFile, encoding, entry);

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java?rev=1150544&r1=1150543&r2=1150544&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ExpandBase.java Mon
Jul 25 04:45:00 2011
@@ -27,6 +27,7 @@ import java.util.Date;
 
 import org.apache.ant.compress.util.ArchiveStreamFactory;
 import org.apache.ant.compress.util.EntryHelper;
+import org.apache.ant.compress.util.Messages;
 
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
@@ -146,8 +147,7 @@ public abstract class ExpandBase extends
             ArchiveEntry ent = null;
             while ((ent = is.getNextEntry()) != null) {
                 if (skipUnreadable && !is.canReadEntryData(ent)) {
-                    log("skipping " + ent.getName()
-                        + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(ent));
                     continue;
                 }
                 empty = false;

Modified: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Unzip.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Unzip.java?rev=1150544&r1=1150543&r2=1150544&view=diff
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Unzip.java (original)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/Unzip.java Mon Jul
25 04:45:00 2011
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.util.Date;
 import java.util.Enumeration;
 
+import org.apache.ant.compress.util.Messages;
 import org.apache.ant.compress.util.ZipStreamFactory;
 
 import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
@@ -65,8 +66,7 @@ public class Unzip extends ExpandBase {
                 empty = false;
                 ZipArchiveEntry ze = (ZipArchiveEntry) e.nextElement();
                 if (getSkipUnreadableEntries() && !zf.canReadEntryData(ze)) {
-                    log("skipping " + ze.getName()
-                        + ", Commons Compress cannot read it");
+                    log(Messages.skippedIsUnreadable(ze));
                     continue;
                 }
                 log("extracting " + ze.getName(), Project.MSG_DEBUG);

Added: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Messages.java
URL: http://svn.apache.org/viewvc/ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Messages.java?rev=1150544&view=auto
==============================================================================
--- ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Messages.java (added)
+++ ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Messages.java Mon Jul
25 04:45:00 2011
@@ -0,0 +1,41 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.ant.compress.util;
+
+import java.text.MessageFormat;
+import org.apache.commons.compress.archivers.ArchiveEntry;
+
+/**
+ * Factored out messages.
+ *
+ * @since Compress Antlib 1.1
+ */
+public final class Messages {
+
+    /**
+     * Message to log when Commons Compress knows it cannot handle a given
+     * entry.
+     */
+    public static String skippedIsUnreadable(ArchiveEntry ent) {
+        return MessageFormat.format("skipping {0}, Apache Commons Compress "
+                                    + "cannot read it.",
+                                    new Object[] { ent.getName() });
+    }
+
+}

Propchange: ant/antlibs/compress/trunk/src/main/org/apache/ant/compress/util/Messages.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message