1.5 test minimize
This commit is contained in:
parent
4e8d42f4b9
commit
becb3f3578
|
|
@ -46,7 +46,7 @@ class RelocateJar extends DefaultTask {
|
||||||
project.logger.info(outJar.getAbsolutePath())
|
project.logger.info(outJar.getAbsolutePath())
|
||||||
int n
|
int n
|
||||||
def buf = new byte[32768]
|
def buf = new byte[32768]
|
||||||
new JarFile(inJar).withCloseable {jarFile ->
|
new JarFile(inJar).withCloseable { jarFile ->
|
||||||
for (def jarEntry : jarFile.entries()) {
|
for (def jarEntry : jarFile.entries()) {
|
||||||
jarFile.getInputStream(jarEntry).withCloseable {
|
jarFile.getInputStream(jarEntry).withCloseable {
|
||||||
if (jarEntry.name.endsWith(".class")) {
|
if (jarEntry.name.endsWith(".class")) {
|
||||||
|
|
@ -54,7 +54,9 @@ class RelocateJar extends DefaultTask {
|
||||||
def reader = new ClassReader(it)
|
def reader = new ClassReader(it)
|
||||||
def writer = new ClassWriter(0)
|
def writer = new ClassWriter(0)
|
||||||
def visitor = new TabooLibClassVisitor(writer, project)
|
def visitor = new TabooLibClassVisitor(writer, project)
|
||||||
reader.accept(new ClassRemapper(visitor, remapper), 0)
|
def rem = new ClassRemapper(visitor, remapper)
|
||||||
|
remapper.remapper = rem
|
||||||
|
reader.accept(rem, 0)
|
||||||
isolated.putAll(visitor.isolated)
|
isolated.putAll(visitor.isolated)
|
||||||
out.putNextEntry(new JarEntry(remapper.map(jarEntry.name)))
|
out.putNextEntry(new JarEntry(remapper.map(jarEntry.name)))
|
||||||
out.write(writer.toByteArray())
|
out.write(writer.toByteArray())
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package io.izzel.taboolib.gradle
|
package io.izzel.taboolib.gradle
|
||||||
|
|
||||||
import groovy.transform.Canonical
|
import groovy.transform.Canonical
|
||||||
|
import org.objectweb.asm.commons.ClassRemapper
|
||||||
import org.objectweb.asm.commons.Remapper
|
import org.objectweb.asm.commons.Remapper
|
||||||
|
|
||||||
@Canonical
|
@Canonical
|
||||||
|
|
@ -8,6 +9,8 @@ class RelocateRemapper extends Remapper {
|
||||||
|
|
||||||
Map<String, String> dot
|
Map<String, String> dot
|
||||||
Map<String, String> slash
|
Map<String, String> slash
|
||||||
|
Map<String, Set<String>> use = new TreeMap()
|
||||||
|
ClassRemapper remapper
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
Object mapValue(Object value) {
|
Object mapValue(Object value) {
|
||||||
|
|
@ -20,8 +23,12 @@ class RelocateRemapper extends Remapper {
|
||||||
return super.mapValue(value)
|
return super.mapValue(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings('GroovyAccessibility')
|
||||||
@Override
|
@Override
|
||||||
String map(String internalName) {
|
String map(String internalName) {
|
||||||
|
if (remapper != null) {
|
||||||
|
use.computeIfAbsent(remapper.className) { new HashSet() }.add(internalName)
|
||||||
|
}
|
||||||
def match = slash.find { internalName.startsWith(it.key) }
|
def match = slash.find { internalName.startsWith(it.key) }
|
||||||
if (match) {
|
if (match) {
|
||||||
return match.value + internalName.substring(match.key.length())
|
return match.value + internalName.substring(match.key.length())
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ class TabooLibExtension {
|
||||||
|
|
||||||
String classifier = "all"
|
String classifier = "all"
|
||||||
|
|
||||||
List<String> modules = new ArrayList<>();
|
List<String> modules = []
|
||||||
|
|
||||||
Map<String, String> relocation = new LinkedHashMap<>()
|
Map<String, String> relocation = new LinkedHashMap<>()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue