package com.github.blindpirate.gogradle.util;

import net.lingala.zip4j.core.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import org.gradle.internal.impldep.org.apache.tools.tar.TarEntry;
import org.gradle.internal.impldep.org.apache.tools.tar.TarInputStream;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

public class CompressUtils {
    public static void decompressZip(File zipFile, File destDir) {
        try {
            ZipFile zF = new ZipFile(zipFile);
            zF.extractAll(destDir.toString());
        } catch (ZipException e) {
            throw ExceptionHandler.uncheckException(e);
        }
    }

    public static void decompressTarGz(File tarGzFile, File destDir) {
        try {
            IOUtils.forceMkdir(destDir);

            TarInputStream tin = new TarInputStream(new GZIPInputStream(new FileInputStream(tarGzFile)));
            TarEntry tarEntry = tin.getNextEntry();
            while (tarEntry != null) {
                File destPath = new File(destDir, tarEntry.getName());
                if (tarEntry.isDirectory()) {
                    IOUtils.forceMkdir(destPath);
                } else {
                    FileOutputStream fout = new FileOutputStream(destPath);
                    tin.copyEntryContents(fout);
                    fout.close();
                }
                tarEntry = tin.getNextEntry();
            }
            tin.close();
        } catch (IOException e) {
            throw ExceptionHandler.uncheckException(e);
        }
    }

    public static void decompressZipOrTarGz(File compressedFile, File destDir) {
        if (compressedFile.getName().endsWith("tar.gz")) {
            decompressTarGz(compressedFile, destDir);
        } else if (compressedFile.getName().endsWith("zip")) {
            decompressZip(compressedFile, destDir);
        } else {
            throw new IllegalArgumentException("Only zip and tar.gz are supported!");
        }
    }
}

@@ -124,24 +124,101 @@
 pException;%0A
+import org.gradle.api.logging.Logger;%0Aimport org.gradle.api.logging.Logging;%0A
 import org.g
@@ -526,16 +526,98 @@
 Utils %7B%0A
+    private static final Logger LOGGER = Logging.getLogger(CompressUtils.class);%0A%0A
     publ
@@ -1850,32 +1850,138 @@
 File destDir) %7B%0A
+        LOGGER.quiet(%22Extracting %7B%7D to %7B%7D%22, compressedFile.getAbsolutePath(), destDir.getAbsolutePath());%0A
         if (comp

Add log before decompressing