22
33
44import com .intellij .openapi .project .Project ;
5- import org .apache .commons .compress .archivers .ArchiveException ;
6- import org .apache .commons .compress .archivers .ArchiveOutputStream ;
7- import org .apache .commons .compress .archivers .ArchiveStreamFactory ;
85import org .apache .commons .compress .archivers .tar .TarArchiveEntry ;
6+ import org .apache .commons .compress .archivers .tar .TarArchiveOutputStream ;
97import org .apache .commons .compress .utils .IOUtils ;
108
119import java .io .*;
1210import java .util .Collection ;
1311import java .util .LinkedList ;
12+ import java .util .zip .GZIPOutputStream ;
1413import java .util .zip .ZipEntry ;
1514import java .util .zip .ZipInputStream ;
1615
@@ -74,10 +73,11 @@ public static File createClasspathArchive(Collection<File> classpathEntries, Pro
7473 }
7574
7675 FileOutputStream fileOutputStream = null ;
77- ArchiveOutputStream archiveOutputStream = null ;
76+ TarArchiveOutputStream archiveOutputStream = null ;
7877 try {
7978 fileOutputStream = new FileOutputStream (archiveFile );
80- archiveOutputStream = new ArchiveStreamFactory ().createArchiveOutputStream (ArchiveStreamFactory .TAR , fileOutputStream );
79+ archiveOutputStream = new TarArchiveOutputStream (new GZIPOutputStream (fileOutputStream ));
80+ archiveOutputStream .setLongFileMode (TarArchiveOutputStream .LONGFILE_GNU );
8181 LinkedList <String > pathElements = new LinkedList <String >();
8282 for (File f : classpathEntries ) {
8383 if (f .isFile ()) { //is a jar file
@@ -92,8 +92,6 @@ public static File createClasspathArchive(Collection<File> classpathEntries, Pro
9292 pathElements .removeLast ();
9393 }
9494 return archiveFile ;
95- } catch (ArchiveException e ) {
96- throw new IOException ();
9795 } finally {
9896 if (archiveOutputStream != null ) {
9997 archiveOutputStream .close ();
@@ -110,8 +108,9 @@ public static File createClasspathArchive(Collection<File> classpathEntries, Pro
110108 * @param archiveOutputStream
111109 * @throws IOException
112110 */
113- private static void writeClassPath (LinkedList <String > pathElements , File entry , ArchiveOutputStream archiveOutputStream ) throws IOException {
111+ private static void writeClassPath (LinkedList <String > pathElements , File entry , TarArchiveOutputStream archiveOutputStream ) throws IOException {
114112 if (entry .isFile ()) {
113+ archiveOutputStream .setLongFileMode (TarArchiveOutputStream .LONGFILE_GNU );
115114 archiveOutputStream .putArchiveEntry (new TarArchiveEntry (entry , getPath (pathElements ) + File .separator + entry .getName ()));
116115 copy (entry , archiveOutputStream );
117116 archiveOutputStream .closeArchiveEntry ();
0 commit comments