| @@ -52,8 +52,8 @@ public class GUnzip extends Unpack { | |||||
| * Implement the gunzipping. | * Implement the gunzipping. | ||||
| */ | */ | ||||
| protected void extract() { | protected void extract() { | ||||
| if (source.lastModified() > dest.lastModified()) { | |||||
| log("Expanding " + source.getAbsolutePath() + " to " | |||||
| if (srcResource.getLastModified() > dest.lastModified()) { | |||||
| log("Expanding " + srcResource.getName() + " to " | |||||
| + dest.getAbsolutePath()); | + dest.getAbsolutePath()); | ||||
| FileOutputStream out = null; | FileOutputStream out = null; | ||||
| @@ -131,6 +131,10 @@ public abstract class Unpack extends Task { | |||||
| } | } | ||||
| if (dest == null) { | if (dest == null) { | ||||
| if (source == null) { | |||||
| throw new BuildException("dest is required when using a non-filesystem source", | |||||
| getLocation()); | |||||
| } | |||||
| dest = new File(source.getParent()); | dest = new File(source.getParent()); | ||||
| } | } | ||||
| @@ -141,7 +145,8 @@ public abstract class Unpack extends Task { | |||||
| } | } | ||||
| private void createDestFile(String defaultExtension) { | private void createDestFile(String defaultExtension) { | ||||
| String sourceName = source.getName(); | |||||
| String sourceName = source == null | |||||
| ? getLastNamePart(srcResource) : source.getName(); | |||||
| int len = sourceName.length(); | int len = sourceName.length(); | ||||
| if (defaultExtension != null | if (defaultExtension != null | ||||
| && len > defaultExtension.length() | && len > defaultExtension.length() | ||||
| @@ -192,4 +197,9 @@ public abstract class Unpack extends Task { | |||||
| return false; | return false; | ||||
| } | } | ||||
| private String getLastNamePart(Resource r) { | |||||
| String n = r.getName(); | |||||
| int idx = n.lastIndexOf("/"); | |||||
| return idx < 0 ? n : n.substring(idx + 1); | |||||
| } | |||||
| } | } | ||||
| @@ -38,7 +38,7 @@ | |||||
| actual="${output}/asf-logo.gif"/> | actual="${output}/asf-logo.gif"/> | ||||
| </target> | </target> | ||||
| <target name="XtestWithNonFileResourceToFile" depends="setup"> | |||||
| <target name="testWithNonFileResourceToFile" depends="setup"> | |||||
| <gunzip dest="${output}/greeting.txt"> | <gunzip dest="${output}/greeting.txt"> | ||||
| <url url="http://ant.apache.org/webtest/gunzip/greeting.txt.gz"/> | <url url="http://ant.apache.org/webtest/gunzip/greeting.txt.gz"/> | ||||
| </gunzip> | </gunzip> | ||||
| @@ -48,7 +48,7 @@ | |||||
| actual="${output}/greeting.txt"/> | actual="${output}/greeting.txt"/> | ||||
| </target> | </target> | ||||
| <target name="XtestWithNonFileResourceToDir" depends="setup"> | |||||
| <target name="testWithNonFileResourceToDir" depends="setup"> | |||||
| <gunzip dest="${output}"> | <gunzip dest="${output}"> | ||||
| <url url="http://ant.apache.org/webtest/gunzip/greeting.txt.gz"/> | <url url="http://ant.apache.org/webtest/gunzip/greeting.txt.gz"/> | ||||
| </gunzip> | </gunzip> | ||||