You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2015/09/12 22:22:14 UTC
[1/2] ant git commit: Make really work with non-filesystem
resources
Repository: ant
Updated Branches:
refs/heads/master 7451a066c -> 3c2ed1374
Make <gunzip> really work with non-filesystem resources
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/7f0eeea1
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/7f0eeea1
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/7f0eeea1
Branch: refs/heads/master
Commit: 7f0eeea180a809355885bfcb6dbb65d5da307849
Parents: 7451a06
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Sep 12 22:14:36 2015 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Sep 12 22:14:36 2015 +0200
----------------------------------------------------------------------
src/main/org/apache/tools/ant/taskdefs/GUnzip.java | 4 ++--
src/main/org/apache/tools/ant/taskdefs/Unpack.java | 12 +++++++++++-
src/tests/antunit/taskdefs/gunzip-test.xml | 4 ++--
3 files changed, 15 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/7f0eeea1/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
index 13e8803..b891bae 100644
--- a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java
@@ -52,8 +52,8 @@ public class GUnzip extends Unpack {
* Implement the gunzipping.
*/
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());
FileOutputStream out = null;
http://git-wip-us.apache.org/repos/asf/ant/blob/7f0eeea1/src/main/org/apache/tools/ant/taskdefs/Unpack.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Unpack.java b/src/main/org/apache/tools/ant/taskdefs/Unpack.java
index 8640f8f..ccc4577 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Unpack.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Unpack.java
@@ -131,6 +131,10 @@ public abstract class Unpack extends Task {
}
if (dest == null) {
+ if (source == null) {
+ throw new BuildException("dest is required when using a non-filesystem source",
+ getLocation());
+ }
dest = new File(source.getParent());
}
@@ -141,7 +145,8 @@ public abstract class Unpack extends Task {
}
private void createDestFile(String defaultExtension) {
- String sourceName = source.getName();
+ String sourceName = source == null
+ ? getLastNamePart(srcResource) : source.getName();
int len = sourceName.length();
if (defaultExtension != null
&& len > defaultExtension.length()
@@ -192,4 +197,9 @@ public abstract class Unpack extends Task {
return false;
}
+ private String getLastNamePart(Resource r) {
+ String n = r.getName();
+ int idx = n.lastIndexOf("/");
+ return idx < 0 ? n : n.substring(idx + 1);
+ }
}
http://git-wip-us.apache.org/repos/asf/ant/blob/7f0eeea1/src/tests/antunit/taskdefs/gunzip-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/taskdefs/gunzip-test.xml b/src/tests/antunit/taskdefs/gunzip-test.xml
index 5c6f82c..e678eb0 100644
--- a/src/tests/antunit/taskdefs/gunzip-test.xml
+++ b/src/tests/antunit/taskdefs/gunzip-test.xml
@@ -38,7 +38,7 @@
actual="${output}/asf-logo.gif"/>
</target>
- <target name="XtestWithNonFileResourceToFile" depends="setup">
+ <target name="testWithNonFileResourceToFile" depends="setup">
<gunzip dest="${output}/greeting.txt">
<url url="http://ant.apache.org/webtest/gunzip/greeting.txt.gz"/>
</gunzip>
@@ -48,7 +48,7 @@
actual="${output}/greeting.txt"/>
</target>
- <target name="XtestWithNonFileResourceToDir" depends="setup">
+ <target name="testWithNonFileResourceToDir" depends="setup">
<gunzip dest="${output}">
<url url="http://ant.apache.org/webtest/gunzip/greeting.txt.gz"/>
</gunzip>
[2/2] ant git commit: Make really work with non-filesystem
resources
Posted by bo...@apache.org.
Make <bunzip2> really work with non-filesystem resources
Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/3c2ed137
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/3c2ed137
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/3c2ed137
Branch: refs/heads/master
Commit: 3c2ed1374f54be5918921d64304ca2c82ca06548
Parents: 7f0eeea
Author: Stefan Bodewig <bo...@apache.org>
Authored: Sat Sep 12 22:21:49 2015 +0200
Committer: Stefan Bodewig <bo...@apache.org>
Committed: Sat Sep 12 22:21:49 2015 +0200
----------------------------------------------------------------------
.../org/apache/tools/ant/taskdefs/BUnzip2.java | 4 +--
src/tests/antunit/taskdefs/bunzip2-test.xml | 26 ++++++++++++++++++--
2 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant/blob/3c2ed137/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java b/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
index 323b738..e4a7995 100644
--- a/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
+++ b/src/main/org/apache/tools/ant/taskdefs/BUnzip2.java
@@ -56,8 +56,8 @@ public class BUnzip2 extends Unpack {
* Do the unbzipping.
*/
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());
FileOutputStream out = null;
http://git-wip-us.apache.org/repos/asf/ant/blob/3c2ed137/src/tests/antunit/taskdefs/bunzip2-test.xml
----------------------------------------------------------------------
diff --git a/src/tests/antunit/taskdefs/bunzip2-test.xml b/src/tests/antunit/taskdefs/bunzip2-test.xml
index a9ca423..fcf05d9 100644
--- a/src/tests/antunit/taskdefs/bunzip2-test.xml
+++ b/src/tests/antunit/taskdefs/bunzip2-test.xml
@@ -18,11 +18,33 @@
<project default="antunit" xmlns:au="antlib:org.apache.ant.antunit">
<import file="../antunit-base.xml" />
- <target name="testExpandArchiveWithMultipleStreams">
+ <target name="setup">
<mkdir dir="${output}"/>
+ </target>
+
+ <target name="testExpandArchiveWithMultipleStreams" depends="setup">
<bunzip2 src="bzip2/multiple.bz2" dest="${output}"/>
<au:assertFilesMatch expected="bzip2/expected"
actual="${output}/multiple"/>
</target>
-</project>
\ No newline at end of file
+ <target name="testWithNonFileResourceToFile" depends="setup">
+ <bunzip2 dest="${output}/greeting.txt">
+ <url url="http://ant.apache.org/webtest/bunzip2/greeting.txt.bz2"/>
+ </bunzip2>
+ <get src="http://ant.apache.org/webtest/gunzip/greeting.txt"
+ dest="${output}/orig.greeting.txt"/>
+ <au:assertFilesMatch expected="${output}/orig.greeting.txt"
+ actual="${output}/greeting.txt"/>
+ </target>
+
+ <target name="testWithNonFileResourceToDir" depends="setup">
+ <bunzip2 dest="${output}">
+ <url url="http://ant.apache.org/webtest/bunzip2/greeting.txt.bz2"/>
+ </bunzip2>
+ <get src="http://ant.apache.org/webtest/gunzip/greeting.txt"
+ dest="${output}/orig.greeting.txt"/>
+ <au:assertFilesMatch expected="${output}/orig.greeting.txt"
+ actual="${output}/greeting.txt"/>
+ </target>
+</project>