Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow overwriting of JarJar output

  • Loading branch information...
commit 6260fff58cc6f691bb88a8f5b0deae373886f5bf 1 parent 2df8dde
Stuart McCulloch authored
Showing with 12 additions and 3 deletions.
  1. +12 −3 src/main/java/com/tonicsystems/jarjar/JarJarMojo.java
15 src/main/java/com/tonicsystems/jarjar/JarJarMojo.java
View
@@ -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
{
Please sign in to comment.
Something went wrong with that request. Please try again.