Permalink
Browse files

Allow overwriting of JarJar output

  • Loading branch information...
1 parent 2df8dde commit 6260fff58cc6f691bb88a8f5b0deae373886f5bf Stuart McCulloch committed Jul 8, 2011
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/main/java/com/tonicsystems/jarjar/JarJarMojo.java
@@ -101,6 +101,13 @@
private boolean skipManifest;
/**
+ * When true, apply JarJar even if output already exists.
+ *
+ * @parameter
+ */
+ private boolean overwrite;
+
+ /**
* @component
*/
private ArchiverManager archiverManager;
@@ -139,12 +146,14 @@ public void execute()
final File inputFile = new File( input );
final File outputFile = new File( output );
+ final boolean inPlaceJarJar = inputFile.equals( outputFile );
+
final File backupFile = new File( outputFile.getParentFile(), "original-" + outputFile.getName() );
if ( backupFile.isDirectory() && backupFile.list().length == 0 )
{
backupFile.delete();
}
- if ( inputFile.equals( outputFile ) && backupFile.exists() )
+ if ( !overwrite && ( inPlaceJarJar && backupFile.exists() || !inPlaceJarJar && outputFile.exists() ) )
{
getLog().info( "Already processed" );
return;
@@ -206,12 +215,12 @@ public void execute()
final File hullZip = new File( workingDirectory, "hull-" + inputFile.getName() );
- StandaloneJarProcessor.run( uberZip, hullZip, processor );
+ StandaloneJarProcessor.run( uberZip, hullZip, processor, true );
processor.strip( hullZip );
final boolean toDirectory = outputFile.isDirectory() || !outputFile.exists() && inputFile.isDirectory();
- if ( inputFile.equals( outputFile ) )
+ if ( inPlaceJarJar )
{
try
{

0 comments on commit 6260fff

Please sign in to comment.