}
protected Archiver createTarArchiver( final String format, final String tarLongFileMode )
throws NoSuchArchiverException, ArchiverException
{
final TarArchiver tarArchiver = (TarArchiver) archiverManager.getArchiver( "tar" );
final int index = format.indexOf( '.' );
if ( index >= 0 )
{
// TODO: this needs a cleanup in plexus archiver - use a real
// typesafe enum
final TarArchiver.TarCompressionMethod tarCompressionMethod = new TarArchiver.TarCompressionMethod();
// TODO: this should accept gz and bz2 as well so we can skip
// over the switch
final String compression = format.substring( index + 1 );
if ( "gz".equals( compression ) )
{
tarCompressionMethod.setValue( "gzip" );
}
else if ( "bz2".equals( compression ) )
{
tarCompressionMethod.setValue( "bzip2" );
}
else
{
// TODO: better handling
throw new IllegalArgumentException( "Unknown compression format: " + compression );
}
tarArchiver.setCompression( tarCompressionMethod );
}
final TarLongFileMode tarFileMode = new TarLongFileMode();
tarFileMode.setValue( tarLongFileMode );
tarArchiver.setLongfile( tarFileMode );
return tarArchiver;
}