Blob Blame History Raw
diff --git a/core/src/main/java/hudson/ClassicPluginStrategy.java b/core/src/main/java/hudson/ClassicPluginStrategy.java
index 040e4cf..6c636fb 100644
--- a/core/src/main/java/hudson/ClassicPluginStrategy.java
+++ b/core/src/main/java/hudson/ClassicPluginStrategy.java
@@ -50,11 +50,14 @@ import org.apache.tools.zip.ZipEntry;
 import org.apache.tools.zip.ZipExtraField;
 import org.apache.tools.zip.ZipOutputStream;
 
+import java.io.BufferedReader;
 import java.io.Closeable;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FilenameFilter;
 import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
 import java.lang.reflect.Field;
 import java.lang.reflect.InvocationTargetException;
 import java.net.URI;
@@ -591,16 +594,44 @@ public class ClassicPluginStrategy implements PluginStrategy {
         }
     }
 
+    private static class StreamGobbler extends Thread {
+        InputStream is;
+
+        public StreamGobbler(InputStream is) {
+            this.is = is;
+        }
+
+        public void run() {
+            try {
+                InputStreamReader isr = new InputStreamReader(is);
+                BufferedReader br = new BufferedReader(isr);
+                String line = null;
+                while ((line = br.readLine()) != null) {
+                    // do nothing
+                }
+            } catch (IOException ioe) {
+                ioe.printStackTrace();
+            }
+        }
+    }
+
     private static void unzipExceptClasses(File archive, File destDir, Project prj) {
-        Expand e = new Expand();
-        e.setProject(prj);
-        e.setTaskType("unzip");
-        e.setSrc(archive);
-        e.setDest(destDir);
-        PatternSet p = new PatternSet();
-        p.setExcludes("WEB-INF/classes/");
-        e.addPatternset(p);
-        e.execute();
+        // TODO: quick hack, this needs to be solved properly
+        try {
+            Runtime rt = Runtime.getRuntime();
+            Process proc = rt.exec("/usr/bin/unzip -o -d " + destDir.getAbsolutePath() + " " + archive.getAbsolutePath()
+                    + " -x 'WEB-INF/classes/*'");
+            StreamGobbler errorGobbler = new StreamGobbler(proc.getErrorStream());
+            StreamGobbler outputGobbler = new StreamGobbler(proc.getInputStream());
+            errorGobbler.start();
+            outputGobbler.start();
+            int rc = proc.waitFor();
+            if (rc != 0) {
+                throw new Exception("unzip exited with return code: " + rc);
+            }
+        } catch (Exception e) {
+            LOGGER.log(Level.SEVERE, "Failed to unzip plugin " + archive, e);
+        }
     }
 
     /**