// Path: src/main/java/com/amazonaws/codepipeline/jenkinsplugin/CodePipelineStateModel.java
// public enum CompressionType {
//     None,
//     Zip,
//     Tar,
//     TarGz
// }


import hudson.model.BuildListener;
import hudson.util.IOUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import com.amazonaws.codepipeline.jenkinsplugin.CodePipelineStateModel.CompressionType;
            final Path pathToCompress,
            final BuildListener listener)
            throws IOException {
        try (final ZipArchiveOutputStream zipArchiveOutputStream =
                     new ZipArchiveOutputStream(
                     new BufferedOutputStream(
                     new FileOutputStream(temporaryZipFile)))) {

            compressArchive(
                    pathToCompress,
                    zipArchiveOutputStream,
                    new ArchiveEntryFactory(CompressionType.Zip),
                    CompressionType.Zip,
                    listener);
        }
    }

    public static void compressTarFile(
            final File temporaryTarFile,
            final Path pathToCompress,
            final BuildListener listener)
            throws IOException {
        try (final TarArchiveOutputStream tarArchiveOutputStream =
                     new TarArchiveOutputStream(
                     new BufferedOutputStream(
                     new FileOutputStream(temporaryTarFile)))) {

            compressArchive(
                    pathToCompress,
                    tarArchiveOutputStream,
// Path: src/main/java/com/amazonaws/codepipeline/jenkinsplugin/CodePipelineStateModel.java
// public enum CompressionType {
//     None,
//     Zip,
//     Tar,
//     TarGz
// }


// Path: src/main/java/com/amazonaws/codepipeline/jenkinsplugin/CompressionTools.java
import hudson.model.BuildListener;
import hudson.util.IOUtils;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.nio.file.FileVisitOption;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.compress.compressors.gzip.GzipCompressorOutputStream;
import com.amazonaws.codepipeline.jenkinsplugin.CodePipelineStateModel.CompressionType;

            final Path pathToCompress,
            final BuildListener listener)
            throws IOException {
        try (final ZipArchiveOutputStream zipArchiveOutputStream =
                     new ZipArchiveOutputStream(
                     new BufferedOutputStream(
                     new FileOutputStream(temporaryZipFile)))) {

            compressArchive(
                    pathToCompress,
                    zipArchiveOutputStream,
                    new ArchiveEntryFactory(CompressionType.Zip),
                    CompressionType.Zip,
                    listener);
        }
    }

    public static void compressTarFile(
            final File temporaryTarFile,
            final Path pathToCompress,
            final BuildListener listener)
            throws IOException {
        try (final TarArchiveOutputStream tarArchiveOutputStream =
                     new TarArchiveOutputStream(
                     new BufferedOutputStream(
                     new FileOutputStream(temporaryTarFile)))) {

            compressArchive(
                    pathToCompress,
                    tarArchiveOutputStream,
                    new ArchiveEntryFactory(CompressionType.Tar),