/**
* check that all contents of the jar are also in the ZIP and up to date.
*
* @param jar jar file containing class files
* @param zip zip file containing class and other files to distribute
*/
static void checkAllJarInZip( File jar, File zip )
{
try
{
if ( !jar.exists() )
{
err.println( "Warning: missing jar " + jar.toString() );
return;
}
if ( !zip.exists() )
{
err.println( "Warning: missing zip " + zip.toString() );
return;
}
ZipFile j = new ZipFile( jar );
ZipFile z = new ZipFile( zip );
for ( Enumeration<? extends ZipEntry> e = j.entries(); e.hasMoreElements(); )
{
final ZipEntry jarEntry = e.nextElement();
final String elementName = jarEntry.getName();
if ( !elementName.startsWith( "META-INF/" ) )
{
final ZipEntry zipEntry = z.getEntry( elementName );
if ( zipEntry == null )
{
err.println( "Warning: " + zip.toString() + "/" + elementName + " missing" );
}
else if ( zipEntry.getSize() != jarEntry.getSize() )
{
err.println( "Warning: " + zip.toString() + "/" + elementName + " size mismatch "
+ ( zipEntry.getSize() - jarEntry.getSize() ) );
}
}
}
j.close();
z.close();
}
catch ( IOException e )
{
e.printStackTrace( System.err );
err.println( "jar or zip i/o problem" );
}
}