com.eed3si9n.jarjar.ScalaSigProcessor.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jarjar-abrams-core_2.12 Show documentation
Show all versions of jarjar-abrams-core_2.12 Show documentation
utility to shade Scala libraries
The newest version!
package com.eed3si9n.jarjar
import org.objectweb.asm.{ ClassReader, ClassWriter }
import util.{ EntryStruct, JarProcessor }
import com.eed3si9n.jarjarabrams.scalasig.ScalaSigClassVisitor
class ScalaSigProcessor(renamer: String => Option[String]) extends JarProcessor {
override def process(struct: EntryStruct): Boolean = {
if (!struct.name.endsWith(".class") || struct.skipTransform) true
else {
val classWriter = new ClassWriter(ClassWriter.COMPUTE_MAXS)
val reader = new ClassReader(struct.data)
reader.accept(new ScalaSigClassVisitor(classWriter, renamer), ClassReader.EXPAND_FRAMES)
struct.data = classWriter.toByteArray
true
}
}
}