diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Expand.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Expand.java
index ec3e1a54c..ed4c6db15 100644
--- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Expand.java
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Expand.java
@@ -8,15 +8,12 @@
package org.apache.tools.ant.taskdefs.archive;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.excalibur.io.IOUtil;
import org.apache.myrmidon.api.TaskContext;
@@ -35,7 +32,7 @@ import org.apache.tools.ant.types.ScannerUtil;
* @author Stefan Bodewig
* @author Magesh Umasankar
*/
-public class Expand
+public abstract class Expand
extends MatchingTask
{
private boolean m_overwrite = true;
@@ -171,46 +168,26 @@ public class Expand
getLogger().info( message );
}
- expandArchive( src, dir );
-
- if( getLogger().isDebugEnabled() )
- {
- final String message = "expand complete";
- getLogger().debug( message );
- }
- }
-
- protected void expandArchive( final File src, final File dir )
- throws TaskException
- {
- ZipInputStream zis = null;
try
{
- // code from WarExpand
- zis = new ZipInputStream( new FileInputStream( src ) );
- ZipEntry ze = null;
-
- while( ( ze = zis.getNextEntry() ) != null )
- {
- final Date date = new Date( ze.getTime() );
- extractFile( dir,
- zis,
- ze.getName(),
- date,
- ze.isDirectory() );
- }
+ expandArchive( src, dir );
}
catch( final IOException ioe )
{
final String message = "Error while expanding " + src.getPath();
throw new TaskException( message, ioe );
}
- finally
+
+ if( getLogger().isDebugEnabled() )
{
- IOUtil.shutdownStream( zis );
+ final String message = "expand complete";
+ getLogger().debug( message );
}
}
+ protected abstract void expandArchive( final File src, final File dir )
+ throws IOException, TaskException;
+
protected void extractFile( final File dir,
final InputStream input,
final String entryName,
diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Untar.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Untar.java
index c2c1f9ac9..ff3cea15a 100644
--- a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Untar.java
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Untar.java
@@ -25,7 +25,7 @@ public class Untar
extends Expand
{
protected void expandArchive( final File src, final File dir )
- throws TaskException
+ throws IOException, TaskException
{
TarInputStream input = null;
FileInputStream fileInput = null;
@@ -44,18 +44,10 @@ public class Untar
entry.isDirectory() );
}
}
- catch( final IOException ioe )
- {
- final String message = "Error while expanding " + src.getPath();
- throw new TaskException( message, ioe );
- }
finally
{
IOUtil.shutdownStream( fileInput );
IOUtil.shutdownStream( input );
}
-
- final String message = "expand complete";
- getLogger().debug( message );
}
}
diff --git a/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Unzip.java b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Unzip.java
new file mode 100644
index 000000000..d9af36b8e
--- /dev/null
+++ b/proposal/myrmidon/src/main/org/apache/tools/ant/taskdefs/archive/Unzip.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.tools.ant.taskdefs.archive;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import org.apache.avalon.excalibur.io.IOUtil;
+import org.apache.myrmidon.api.TaskException;
+
+/**
+ * Untar a file. Heavily based on the Expand task.
+ *
+ * @author Stefan Bodewig
+ * @author Magesh Umasankar
+ */
+public class Unzip
+ extends Expand
+{
+ protected void expandArchive( final File src, final File dir )
+ throws IOException, TaskException
+ {
+ ZipInputStream zis = null;
+ try
+ {
+ // code from WarExpand
+ zis = new ZipInputStream( new FileInputStream( src ) );
+ ZipEntry ze = null;
+
+ while( ( ze = zis.getNextEntry() ) != null )
+ {
+ final Date date = new Date( ze.getTime() );
+ extractFile( dir,
+ zis,
+ ze.getName(),
+ date,
+ ze.isDirectory() );
+ }
+ }
+ finally
+ {
+ IOUtil.shutdownStream( zis );
+ }
+ }
+}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Expand.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Expand.java
index ec3e1a54c..ed4c6db15 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Expand.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Expand.java
@@ -8,15 +8,12 @@
package org.apache.tools.ant.taskdefs.archive;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Date;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
import org.apache.avalon.excalibur.io.FileUtil;
import org.apache.avalon.excalibur.io.IOUtil;
import org.apache.myrmidon.api.TaskContext;
@@ -35,7 +32,7 @@ import org.apache.tools.ant.types.ScannerUtil;
* @author Stefan Bodewig
* @author Magesh Umasankar
*/
-public class Expand
+public abstract class Expand
extends MatchingTask
{
private boolean m_overwrite = true;
@@ -171,46 +168,26 @@ public class Expand
getLogger().info( message );
}
- expandArchive( src, dir );
-
- if( getLogger().isDebugEnabled() )
- {
- final String message = "expand complete";
- getLogger().debug( message );
- }
- }
-
- protected void expandArchive( final File src, final File dir )
- throws TaskException
- {
- ZipInputStream zis = null;
try
{
- // code from WarExpand
- zis = new ZipInputStream( new FileInputStream( src ) );
- ZipEntry ze = null;
-
- while( ( ze = zis.getNextEntry() ) != null )
- {
- final Date date = new Date( ze.getTime() );
- extractFile( dir,
- zis,
- ze.getName(),
- date,
- ze.isDirectory() );
- }
+ expandArchive( src, dir );
}
catch( final IOException ioe )
{
final String message = "Error while expanding " + src.getPath();
throw new TaskException( message, ioe );
}
- finally
+
+ if( getLogger().isDebugEnabled() )
{
- IOUtil.shutdownStream( zis );
+ final String message = "expand complete";
+ getLogger().debug( message );
}
}
+ protected abstract void expandArchive( final File src, final File dir )
+ throws IOException, TaskException;
+
protected void extractFile( final File dir,
final InputStream input,
final String entryName,
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Untar.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Untar.java
index c2c1f9ac9..ff3cea15a 100644
--- a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Untar.java
+++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Untar.java
@@ -25,7 +25,7 @@ public class Untar
extends Expand
{
protected void expandArchive( final File src, final File dir )
- throws TaskException
+ throws IOException, TaskException
{
TarInputStream input = null;
FileInputStream fileInput = null;
@@ -44,18 +44,10 @@ public class Untar
entry.isDirectory() );
}
}
- catch( final IOException ioe )
- {
- final String message = "Error while expanding " + src.getPath();
- throw new TaskException( message, ioe );
- }
finally
{
IOUtil.shutdownStream( fileInput );
IOUtil.shutdownStream( input );
}
-
- final String message = "expand complete";
- getLogger().debug( message );
}
}
diff --git a/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Unzip.java b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Unzip.java
new file mode 100644
index 000000000..d9af36b8e
--- /dev/null
+++ b/proposal/myrmidon/src/todo/org/apache/tools/ant/taskdefs/archive/Unzip.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) The Apache Software Foundation. All rights reserved.
+ *
+ * This software is published under the terms of the Apache Software License
+ * version 1.1, a copy of which has been included with this distribution in
+ * the LICENSE.txt file.
+ */
+package org.apache.tools.ant.taskdefs.archive;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Date;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
+import org.apache.avalon.excalibur.io.IOUtil;
+import org.apache.myrmidon.api.TaskException;
+
+/**
+ * Untar a file. Heavily based on the Expand task.
+ *
+ * @author Stefan Bodewig
+ * @author Magesh Umasankar
+ */
+public class Unzip
+ extends Expand
+{
+ protected void expandArchive( final File src, final File dir )
+ throws IOException, TaskException
+ {
+ ZipInputStream zis = null;
+ try
+ {
+ // code from WarExpand
+ zis = new ZipInputStream( new FileInputStream( src ) );
+ ZipEntry ze = null;
+
+ while( ( ze = zis.getNextEntry() ) != null )
+ {
+ final Date date = new Date( ze.getTime() );
+ extractFile( dir,
+ zis,
+ ze.getName(),
+ date,
+ ze.isDirectory() );
+ }
+ }
+ finally
+ {
+ IOUtil.shutdownStream( zis );
+ }
+ }
+}