diff options
author | Stefan Zeiger <szeiger@novocode.com> | 2015-11-11 15:38:08 +0100 |
---|---|---|
committer | Stefan Zeiger <szeiger@novocode.com> | 2015-11-24 12:44:38 +0100 |
commit | 62f346b6574a72d236b04ba8744b7a8ea2bcdfe2 (patch) | |
tree | 1b46c066d248bc617c2c87fcd8fb3db69b532407 /project/JarJar.scala | |
parent | 03607b219aa854c3d36ae572d2ac6fca8a1bd29e (diff) | |
download | scala-62f346b6574a72d236b04ba8744b7a8ea2bcdfe2.tar.gz scala-62f346b6574a72d236b04ba8744b7a8ea2bcdfe2.tar.bz2 scala-62f346b6574a72d236b04ba8744b7a8ea2bcdfe2.zip |
Fix JarJar “Keep” processing in sbt build
It is not enough to check the return value of `process()` to determine
whether a class file should be kept or deleted. The classes that should
not be kept are only known after processing everything and files that
have already been written to disk may need to be deleted.
Diffstat (limited to 'project/JarJar.scala')
-rw-r--r-- | project/JarJar.scala | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/project/JarJar.scala b/project/JarJar.scala index 64281f23c1..2eec0e9033 100644 --- a/project/JarJar.scala +++ b/project/JarJar.scala @@ -55,7 +55,7 @@ object JarJar { def apply(in: Iterator[Entry], outdir: File, config: Seq[JarJarConfig], verbose: Boolean = false): Seq[File] = { val patterns = config.map(_.toPatternElement).asJava - val processor: JarProcessor = newMainProcessor(patterns, verbose, false) + val processor = newMainProcessor(patterns, verbose, false) def process(e: Entry): Option[File] = { val struct = new EntryStruct() struct.name = e.name @@ -77,7 +77,16 @@ object JarJar { } else None } - in.flatMap(entry => process(entry)).toList - + val processed = in.flatMap(entry => process(entry)).toSet + val getter = processor.getClass.getDeclaredMethod("getExcludes") + getter.setAccessible(true) + val excludes = getter.invoke(processor).asInstanceOf[java.util.Set[String]].asScala + val excluded = excludes.map { name => + val f: File = outdir / name + if(f.exists && !f.delete()) + throw new IOException("Failed to delete excluded file $f") + f + } + (processed -- excluded).toSeq } } |