Return-Path: Delivered-To: apmail-ant-notifications-archive@minotaur.apache.org Received: (qmail 3454 invoked from network); 11 Sep 2009 10:55:45 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 11 Sep 2009 10:55:45 -0000 Received: (qmail 60447 invoked by uid 500); 11 Sep 2009 10:55:45 -0000 Delivered-To: apmail-ant-notifications-archive@ant.apache.org Received: (qmail 60399 invoked by uid 500); 11 Sep 2009 10:55:45 -0000 Mailing-List: contact notifications-help@ant.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ant.apache.org Delivered-To: mailing list notifications@ant.apache.org Received: (qmail 60390 invoked by uid 99); 11 Sep 2009 10:55:45 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Sep 2009 10:55:45 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 11 Sep 2009 10:55:41 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 7F04423888BD; Fri, 11 Sep 2009 10:55:20 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r813774 - /ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java Date: Fri, 11 Sep 2009 10:55:19 -0000 To: notifications@ant.apache.org From: bodewig@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090911105520.7F04423888BD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: bodewig Date: Fri Sep 11 10:55:16 2009 New Revision: 813774 URL: http://svn.apache.org/viewvc?rev=813774&view=rev Log: make protected access of some methods more useful by providing access to some needed private members Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java Modified: ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java URL: http://svn.apache.org/viewvc/ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java?rev=813774&r1=813773&r2=813774&view=diff ============================================================================== --- ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java (original) +++ ant/sandbox/antlibs/compress/trunk/src/main/org/apache/ant/compress/taskdefs/ArchiveBase.java Fri Sep 11 10:55:16 2009 @@ -93,14 +93,26 @@ this.factory = factory; } + protected final ArchiveStreamFactory getFactory() { + return factory; + } + protected final void setEntryBuilder(EntryBuilder builder) { this.entryBuilder = builder; } + protected final EntryBuilder getEntryBuilder() { + return entryBuilder; + } + protected final void setFileSetBuilder(FileSetBuilder builder) { this.fileSetBuilder = builder; } + protected final FileSetBuilder getFileSetBuilder() { + return fileSetBuilder; + } + /** * The archive to create. */ @@ -128,6 +140,10 @@ dest = r; } + protected Resource getDest() { + return dest; + } + /** * Sources for the archive. */ @@ -150,6 +166,13 @@ } /** + * Encoding of file names. + */ + public String getEncoding() { + return encoding; + } + + /** * Whether only file entries should be added to the archive. */ public void setFilesOnly(boolean b) { @@ -157,6 +180,13 @@ } /** + * Whether only file entries should be added to the archive. + */ + protected boolean isFilesOnly() { + return filesOnly; + } + + /** * Whether 0 permissions read from an archive should be considered * real permissions (that should be preserved) or missing * permissions (which is the default). @@ -221,7 +251,7 @@ public void execute() { validate(); - if (!dest.isExists()) { + if (!getDest().isExists()) { // force create mode mode = new Mode(); mode.setValue(Mode.FORCE_CREATE); @@ -242,8 +272,8 @@ try { if (!Mode.FORCE_CREATE.equals(mode.getValue()) && !Mode.FORCE_REPLACE.equals(mode.getValue()) - && isUpToDate(toAdd)) { - log(dest + " is up-to-date, nothing to do."); + && isUpToDate(toAdd, getDest())) { + log(getDest() + " is up-to-date, nothing to do."); return; } } catch (IOException ioex) { @@ -273,7 +303,7 @@ throw new BuildException("subclass didn't provide an fileSetBuilder" + " instance"); } - if (dest == null) { + if (getDest() == null) { throw new BuildException("must provide a destination resource"); } if (sources.size() == 0) { @@ -293,7 +323,7 @@ ResourceCollectionFlags rcFlags = getFlags(rc); for (Iterator rs = rc.iterator(); rs.hasNext(); ) { Resource r = (Resource) rs.next(); - if (!filesOnly || !r.isDirectory()) { + if (!isFilesOnly() || !r.isDirectory()) { ResourceWithFlags rwf = new ResourceWithFlags(r, rcFlags, getFlags(r)); String name = rwf.getName(); @@ -322,9 +352,13 @@ * *

Will only ever be invoked if the target exists.

* + * @param src the resources that have been found as sources + * @param targetArchive the target archive + * * @return true if the target is up-to-date */ - protected boolean isUpToDate(ResourceWithFlags[] src) throws IOException { + protected boolean isUpToDate(ResourceWithFlags[] src, + Resource targetArchive) throws IOException { final Resource[] srcResources = new Resource[src.length]; for (int i = 0; i < srcResources.length; i++) { srcResources[i] = @@ -334,7 +368,7 @@ return ResourceUtils .selectOutOfDateSources(this, srcResources, new IdentityMapper(), - fileSetBuilder.buildFileSet(dest) + fileSetBuilder.buildFileSet(targetArchive) .getDirectoryScanner(getProject())) .length == 0; } @@ -349,13 +383,13 @@ Set addedDirectories = new HashSet(); try { out = - factory.getArchiveStream(new BufferedOutputStream(dest + factory.getArchiveStream(new BufferedOutputStream(getDest() .getOutputStream()), - Expand.NATIVE_ENCODING.equals(encoding) - ? null : encoding); + Expand.NATIVE_ENCODING.equals(getEncoding()) + ? null : getEncoding()); for (int i = 0; i < src.length; i++) { - if (!filesOnly) { + if (!isFilesOnly()) { ensureParentDirs(out, src[i], addedDirectories); }