submitted by Jeff Martin <jeff@custommonkey.org> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271573 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -75,6 +75,9 @@ Fixed bugs: | |||||
| Other changes: | Other changes: | ||||
| -------------- | -------------- | ||||
| * gzip now checks that the zipfile is older than the source file | |||||
| before rebuilding the zipfile. | |||||
| * New task <loadfile> to load a whole file into a property | * New task <loadfile> to load a whole file into a property | ||||
| * New task <echoproperties> to list your current properties to the screen | * New task <echoproperties> to list your current properties to the screen | ||||
| @@ -22,6 +22,11 @@ | |||||
| <gzip src="../asf-logo.gif" zipfile="asf-logo.gif.gz" /> | <gzip src="../asf-logo.gif" zipfile="asf-logo.gif.gz" /> | ||||
| </target> | </target> | ||||
| <target name="testDateCheck"> | |||||
| <touch file="asf-logo.gif.gz"/> | |||||
| <gzip src="../asf-logo.gif" zipfile="asf-logo.gif.gz" /> | |||||
| </target> | |||||
| <target name="cleanup"> | <target name="cleanup"> | ||||
| <delete file="asf-logo.gif.gz" /> | <delete file="asf-logo.gif.gz" /> | ||||
| </target> | </target> | ||||
| @@ -83,11 +83,11 @@ public abstract class Pack extends Task { | |||||
| } | } | ||||
| private void validate() { | private void validate() { | ||||
| if (zipFile == null) { | |||||
| if (zipFile == null || zipFile.getName().equals("")) { | |||||
| throw new BuildException("zipfile attribute is required", location); | throw new BuildException("zipfile attribute is required", location); | ||||
| } | } | ||||
| if (source == null) { | |||||
| if (source == null || source.getName().equals("")) { | |||||
| throw new BuildException("src attribute is required", location); | throw new BuildException("src attribute is required", location); | ||||
| } | } | ||||
| @@ -99,8 +99,14 @@ public abstract class Pack extends Task { | |||||
| public void execute() throws BuildException { | public void execute() throws BuildException { | ||||
| validate(); | validate(); | ||||
| log("Building: " + zipFile.getAbsolutePath()); | |||||
| pack(); | |||||
| if(zipFile.lastModified() < source.lastModified()){ | |||||
| log("Building: " + zipFile.getAbsolutePath()); | |||||
| pack(); | |||||
| }else{ | |||||
| log("Nothing to do: " + zipFile.getAbsolutePath() + | |||||
| " is up to date."); | |||||
| } | |||||
| } | } | ||||
| private void zipFile(InputStream in, OutputStream zOut) | private void zipFile(InputStream in, OutputStream zOut) | ||||
| @@ -86,4 +86,25 @@ public class GzipTest extends BuildFileTest { | |||||
| expectBuildException("test4", "attribute zipfile invalid"); | expectBuildException("test4", "attribute zipfile invalid"); | ||||
| } | } | ||||
| public void testGZip(){ | |||||
| executeTarget("realTest"); | |||||
| String log = getLog(); | |||||
| assertTrue("Expecting message starting with 'Building:' but got '" | |||||
| + log + "'", log.startsWith("Building:")); | |||||
| assertTrue("Expecting message ending with 'asf-logo.gif.gz' but got '" | |||||
| + log + "'", log.endsWith("asf-logo.gif.gz")); | |||||
| } | |||||
| public void testDateCheck(){ | |||||
| executeTarget("testDateCheck"); | |||||
| String log = getLog(); | |||||
| assertTrue( | |||||
| "Expecting message ending with 'asf-logo.gif.gz is up to date.' but got '" + log + "'", | |||||
| log.endsWith("asf-logo.gif.gz is up to date.")); | |||||
| } | |||||
| public void tearDown(){ | |||||
| executeTarget("cleanup"); | |||||
| } | |||||
| } | } | ||||