johnrengelman/shadow — pull request #16 by mlueders (2013-08-04 17:43:50+00:00)
Title: Jar conflict when shadow basename matches jar basename

DefaultCaster expects that shadowRequest.uberJar does not exist when cast is invoked. However, if shadow baseName matches jar baseName, this is not the case and it overwrites the jar when it creates the JarOutputStream.

This patch simply uses a temporary file to generate the initial jar and then renames the jar when processing is complete.

One note: I don't have a windows system readily available to test this on. It's possible renaming a file to a file which already exists will fail under windows. If so, it should be a simple matter to delete the file before rename. However, I can't test this so I'm leaving out that logic.