Skip to content
Permalink
Browse files
Use Apache Commons IO to copy streams instead of custom code.
  • Loading branch information
garydgregory committed May 18, 2018
1 parent 9eda264 commit 20ed13cd7aa90f4fd88711feee6f064bb108a9b7
Showing 1 changed file with 11 additions and 16 deletions.
@@ -16,26 +16,26 @@
*/
package org.apache.commons.release.plugin.mojos;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.commons.compress.archivers.zip.ParallelScatterZipCreator;
import org.apache.commons.compress.archivers.zip.ScatterZipOutputStream;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.release.plugin.SharedFunctions;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

/**
* Takes the built <code>./target/site</code> directory and compresses it to
* <code>./target/commons-release-plugin/site.zip</code>.
@@ -183,12 +183,7 @@ private void addToZip(File directoryToZip, File file, ZipOutputStream zos) throw
file.getCanonicalPath().length());
ZipEntry zipEntry = new ZipEntry(zipFilePath);
zos.putNextEntry(zipEntry);
byte[] bytes = new byte[SharedFunctions.BUFFER_BYTE_SIZE];
int length;
while ((length = fis.read(bytes)) >= 0) {
zos.write(bytes, 0, length);
}
zos.closeEntry();
IOUtils.copy(fis, zos);
}
}
}

0 comments on commit 20ed13c

Please sign in to comment.