Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions webstart-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@

<dependencies>

<dependency>
<groupId> org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.24.0</version>
</dependency>


<dependency>
<groupId>org.codehaus.mojo</groupId>
<artifactId>keytool-api-1.7</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,17 @@ public boolean isPack200()
return pack200 != null && pack200.isEnabled();
}

/**
* Returns the flag that indicates whether or not jar resources
* will be compressed using the Apache Commons Compress pack200 variant.
*
* @return Returns the value of the pack200.enabled field.
*/
public boolean isCommonsCompressEnabled()
{
return pack200 != null && pack200.isCommonsCompressEnabled();
}

/**
* Returns the files to be passed without pack200 compression.
*
Expand Down Expand Up @@ -691,7 +702,7 @@ protected void signOrRenameJars()

// http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/pack200.html
// we need to pack then unpack the files before signing them
unpackJars( getLibDirectory() );
unpackJars( getLibDirectory(), isCommonsCompressEnabled() );

// As out current Pack200 ant tasks don't give us the ability to use a temporary area for
// creating those temporary packing, we have to delete the temporary files.
Expand Down Expand Up @@ -733,7 +744,7 @@ protected void pack200Jars( File directory, FileFilter filter )
{
try
{
getPack200Tool().packJars( directory, filter, isGzip(), getPack200PassFiles() );
getPack200Tool().packJars( directory, filter, isGzip(), getPack200PassFiles(), isCommonsCompressEnabled() );
}
catch ( IOException e )
{
Expand Down Expand Up @@ -798,7 +809,7 @@ protected void verboseLog( String msg )
// Private Methods
// ----------------------------------------------------------------------

private void unpackJars( File directory )
private void unpackJars( File directory, boolean commonsCompress )
throws MojoExecutionException
{
getLog().info( "-- Unpack jars before sign operation " );
Expand All @@ -812,7 +823,7 @@ private void unpackJars( File directory )
// then unpack
try
{
getPack200Tool().unpackJars( directory, unprocessedPack200FileFilter );
getPack200Tool().unpackJars( directory, unprocessedPack200FileFilter, commonsCompress );
}
catch ( IOException e )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,7 @@ private void checkInput()
getLog().debug( "basedir " + this.basedir );
getLog().debug( "gzip " + isGzip() );
getLog().debug( "pack200 " + isPack200() );
getLog().debug( "Commons Compress pack200 " + isCommonsCompressEnabled() );
getLog().debug( "project " + this.getProject() );
getLog().debug( "verbose " + isVerbose() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@ public boolean isPack200()
return globalConfig.isPack200();
}

/**
* Returns the flag that indicates whether or not jar resources
* will be compressed using pack200.
*
* @return Returns the value of the pack200.enabled field.
*/
public boolean isCommonsCompressEnabled()
{
return globalConfig.isCommonsCompressEnabled();
}

/**
* Returns the files to be passed without pack200 compression.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,10 @@ public boolean isPack200()
{
return pack200 != null && pack200.isEnabled();
}


public boolean isCommonsCompressEnabled()
{
return pack200 != null && pack200.isCommonsCompressEnabled();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public File execute( JnlpDependencyConfig config, File file )
verboseLog( config, "Pack200 file: " + file );
try
{
File result = pack200Tool.packJar( file, config.isGzip(), config.getPack200PassFiles() );
File result = pack200Tool.packJar( file, config.isGzip(), config.getPack200PassFiles(), config.isCommonsCompressEnabled() );
getLogger().debug( "packed200 file: " + result );
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public File execute( JnlpDependencyConfig config, File file )
verboseLog( config, "Unpack 200 file: " + file );
try
{
File result = pack200Tool.unpackJar( file );
File result = pack200Tool.unpackJar( file, config.isCommonsCompressEnabled() );
getLogger().debug( "Unpacked 200 file: " + result );
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
public class UpdateManifestTask
extends AbstractJnlpTask
{

private static final String INDEX_LIST = "META-INF/INDEX.LIST";

public static final String ROLE_HINT = "UpdateManifestTask";

@Requirement
Expand Down Expand Up @@ -124,6 +127,11 @@ private File updateManifestEntries( File jar, Map<String, String> manifestentrie
{
continue;
}
//skip the INDEX.LIST file
if (INDEX_LIST.equals(entry.getName()))
{
continue;
}

ZipEntry newEntry = new ZipEntry( entry.getName() );
targetJar.putNextEntry( newEntry );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class DefaultPack200Tool
public static final String PACK_EXTENSION = ".pack";

@Override
public void pack( File source, File destination, Map<String, String> props, boolean gzip )
public void pack( File source, File destination, Map<String, String> props, boolean gzip, boolean commonsCompress )
throws IOException
{
JarFile jar = null;
Expand All @@ -81,9 +81,15 @@ public void pack( File source, File destination, Map<String, String> props, bool

jar = new JarFile( source, false );

Pack200.Packer packer = Pack200.newPacker();
packer.properties().putAll( props );
packer.pack( jar, out );
if (commonsCompress) {
org.apache.commons.compress.java.util.jar.Pack200.Packer packer = org.apache.commons.compress.java.util.jar.Pack200.newPacker();
packer.properties().putAll( props );
packer.pack( jar, out );
} else {
Pack200.Packer packer = Pack200.newPacker();
packer.properties().putAll( props );
packer.pack( jar, out );
}
}
finally
{
Expand All @@ -96,15 +102,15 @@ public void pack( File source, File destination, Map<String, String> props, bool
}

@Override
public void repack( File source, File destination, Map<String, String> props )
throws IOException
public void repack( File source, File destination, Map<String, String> props, boolean commonsCompress )
throws IOException
{
File tempFile = new File( source.toString() + ".tmp" );

try
{
pack( source, tempFile, props, false );
unpack( tempFile, destination, props );
pack( source, tempFile, props, false, commonsCompress );
unpack( tempFile, destination, props, commonsCompress );
}
finally
{
Expand All @@ -113,7 +119,7 @@ public void repack( File source, File destination, Map<String, String> props )
}

@Override
public void unpack( File source, File destination, Map<String, String> props )
public void unpack( File source, File destination, Map<String, String> props, boolean commonsCompress )
throws IOException
{
InputStream in = null;
Expand All @@ -129,9 +135,15 @@ public void unpack( File source, File destination, Map<String, String> props )

out = new JarOutputStream( new BufferedOutputStream( new FileOutputStream( destination ) ) );

Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.properties().putAll( props );
unpacker.unpack( in, out );
if (commonsCompress) {
org.apache.commons.compress.java.util.jar.Pack200.Unpacker unpacker = org.apache.commons.compress.java.util.jar.Pack200.newUnpacker();
unpacker.properties().putAll( props );
unpacker.unpack( in, out );
} else {
Pack200.Unpacker unpacker = Pack200.newUnpacker();
unpacker.properties().putAll( props );
unpacker.unpack( in, out );
}
}
finally
{
Expand All @@ -141,7 +153,7 @@ public void unpack( File source, File destination, Map<String, String> props )
}

@Override
public void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<String> passFiles )
public void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<String> passFiles, boolean commonsCompress )
throws IOException
{
// getLog().debug( "packJars for " + directory );
Expand Down Expand Up @@ -171,13 +183,13 @@ public void packJars( File directory, FileFilter jarFileFilter, boolean gzip, Li
}
}

pack( jarFile, pack200Jar, propMap, gzip );
pack( jarFile, pack200Jar, propMap, gzip, commonsCompress );
setLastModified( pack200Jar, jarFile.lastModified() );
}
}

@Override
public File packJar( File jarFile, boolean gzip, List<String> passFiles )
public File packJar( File jarFile, boolean gzip, List<String> passFiles, boolean commonsCompress)
throws IOException
{
final String extension = gzip ? PACK_GZ_EXTENSION : PACK_EXTENSION;
Expand All @@ -199,14 +211,14 @@ public File packJar( File jarFile, boolean gzip, List<String> passFiles )
}
}

pack( jarFile, pack200Jar, propMap, gzip );
pack( jarFile, pack200Jar, propMap, gzip, commonsCompress );
setLastModified( pack200Jar, jarFile.lastModified() );
return pack200Jar;
}


@Override
public void unpackJars( File directory, FileFilter pack200FileFilter )
public void unpackJars( File directory, FileFilter pack200FileFilter, boolean commonsCompress )
throws IOException
{
// getLog().debug( "unpackJars for " + directory );
Expand All @@ -220,13 +232,13 @@ public void unpackJars( File directory, FileFilter pack200FileFilter )

deleteFile( jarFile );

unpack( packFile, jarFile, Collections.<String, String>emptyMap() );
unpack( packFile, jarFile, Collections.<String, String>emptyMap(), commonsCompress );
setLastModified( jarFile, packFile.lastModified() );
}
}

@Override
public File unpackJar( File packFile )
public File unpackJar( File packFile, boolean commonsCompress )
throws IOException
{
final String packedJarPath = packFile.getAbsolutePath();
Expand All @@ -236,7 +248,7 @@ public File unpackJar( File packFile )

deleteFile( jarFile );

unpack( packFile, jarFile, Collections.<String, String>emptyMap() );
unpack( packFile, jarFile, Collections.<String, String>emptyMap(), commonsCompress );
setLastModified( jarFile, packFile.lastModified() );
return jarFile;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ public class Pack200Config
*/
private boolean enabled;

/**
* Whether the commons compress version of pack200 is enabled
*
* @see #isCommonsCompressEnabled()
*/
private boolean commonsCompressEnabled;

/**
* The files to be passed without compression.
*
Expand Down Expand Up @@ -83,4 +90,12 @@ public void setPassFiles( List<String> passFiles )
this.passFiles = passFiles;
}

public boolean isCommonsCompressEnabled() {
return commonsCompressEnabled;
}

public void setCommonsCompressEnabled(boolean commonsCompressEnabled) {
this.commonsCompressEnabled = commonsCompressEnabled;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public interface Pack200Tool
* @param gzip true if the destination file
* @throws IOException TODO
*/
void pack( File source, File destination, Map<String, String> props, boolean gzip )
void pack( File source, File destination, Map<String, String> props, boolean gzip, boolean commonsCompress )
throws IOException;

/**
Expand All @@ -69,7 +69,7 @@ void pack( File source, File destination, Map<String, String> props, boolean gzi
* @param props the packing properties
* @throws IOException TODO
*/
void repack( File source, File destination, Map<String, String> props )
void repack( File source, File destination, Map<String, String> props, boolean commonsCompress )
throws IOException;

/**
Expand All @@ -80,7 +80,7 @@ void repack( File source, File destination, Map<String, String> props )
* @param props the packing properties
* @throws IOException TODO
*/
void unpack( File source, File destination, Map<String, String> props )
void unpack( File source, File destination, Map<String, String> props, boolean commonsCompress )
throws IOException;

/**
Expand All @@ -94,7 +94,7 @@ void unpack( File source, File destination, Map<String, String> props )
* @param passFiles the list of file names to be passed as not pack200 compressed
* @throws IOException TODO
*/
void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<String> passFiles )
void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<String> passFiles, boolean commonsCompress )
throws IOException;

/**
Expand All @@ -106,7 +106,7 @@ void packJars( File directory, FileFilter jarFileFilter, boolean gzip, List<Stri
* @return the packed file
* @throws IOException TODO
*/
File packJar( File jarFile, boolean gzip, List<String> passFiles )
File packJar( File jarFile, boolean gzip, List<String> passFiles, boolean commonsCompress )
throws IOException;

/**
Expand All @@ -116,7 +116,7 @@ File packJar( File jarFile, boolean gzip, List<String> passFiles )
* @param pack200FileFilter the fileter to determin which files to unpakc
* @throws IOException TODO
*/
void unpackJars( File directory, FileFilter pack200FileFilter )
void unpackJars( File directory, FileFilter pack200FileFilter, boolean commonsCompress )
throws IOException;

/**
Expand All @@ -126,6 +126,6 @@ void unpackJars( File directory, FileFilter pack200FileFilter )
* @return the unpacked file
* @throws IOException TODO
*/
File unpackJar( File packFile )
File unpackJar( File packFile, boolean commonsCompress )
throws IOException;
}
Loading