1.5 test minimize
This commit is contained in:
parent
84ef9b98db
commit
4e8d42f4b9
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'io.izzel.taboolib'
|
group 'io.izzel.taboolib'
|
||||||
version '1.5'
|
version '1.6'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
embed
|
embed
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
package io.izzel.taboolib.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.objectweb.asm.AnnotationVisitor
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
|
import org.objectweb.asm.Type
|
||||||
|
|
||||||
|
class IsolatedAnnotationVisitor extends AnnotationVisitor {
|
||||||
|
|
||||||
|
String name
|
||||||
|
Project project
|
||||||
|
TabooLibClassVisitor parent
|
||||||
|
|
||||||
|
IsolatedAnnotationVisitor(AnnotationVisitor annotationVisitor, project, name, parent) {
|
||||||
|
super(Opcodes.ASM7, annotationVisitor)
|
||||||
|
this.name = name
|
||||||
|
this.project = project
|
||||||
|
this.parent = parent
|
||||||
|
this.parent.isolated[name] = new ArrayList<>()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
AnnotationVisitor visitArray(String name) {
|
||||||
|
return new IsolatedExcludeAnnotationVisitor(super.visitArray(name), this)
|
||||||
|
}
|
||||||
|
|
||||||
|
class IsolatedExcludeAnnotationVisitor extends AnnotationVisitor {
|
||||||
|
|
||||||
|
IsolatedAnnotationVisitor parent
|
||||||
|
|
||||||
|
IsolatedExcludeAnnotationVisitor(AnnotationVisitor annotationVisitor, parent) {
|
||||||
|
super(Opcodes.ASM7, annotationVisitor)
|
||||||
|
this.parent = parent
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void visit(String name, Object value) {
|
||||||
|
parent.parent.isolated[parent.name] += (value as Type).className
|
||||||
|
super.visit(name, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -41,6 +41,7 @@ class RelocateJar extends DefaultTask {
|
||||||
def name = inJar.name.substring(0, index) + (classifier == null ? "" : "-" + classifier) + inJar.name.substring(index)
|
def name = inJar.name.substring(0, index) + (classifier == null ? "" : "-" + classifier) + inJar.name.substring(index)
|
||||||
def outJar = new File(inJar.getParentFile(), name)
|
def outJar = new File(inJar.getParentFile(), name)
|
||||||
def tmpOut = File.createTempFile(name, ".jar")
|
def tmpOut = File.createTempFile(name, ".jar")
|
||||||
|
def isolated = new HashMap<String, List<String>>()
|
||||||
new JarOutputStream(new FileOutputStream(tmpOut)).withCloseable { out ->
|
new JarOutputStream(new FileOutputStream(tmpOut)).withCloseable { out ->
|
||||||
project.logger.info(outJar.getAbsolutePath())
|
project.logger.info(outJar.getAbsolutePath())
|
||||||
int n
|
int n
|
||||||
|
|
@ -54,6 +55,7 @@ class RelocateJar extends DefaultTask {
|
||||||
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)
|
reader.accept(new ClassRemapper(visitor, remapper), 0)
|
||||||
|
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())
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -7,19 +7,34 @@ import org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
class TabooLibClassVisitor extends ClassVisitor {
|
class TabooLibClassVisitor extends ClassVisitor {
|
||||||
|
|
||||||
|
String name
|
||||||
Project project
|
Project project
|
||||||
|
Map<String, List<String>> isolated = new HashMap()
|
||||||
|
|
||||||
TabooLibClassVisitor(ClassVisitor classVisitor, Project project) {
|
TabooLibClassVisitor(ClassVisitor classVisitor, Project project) {
|
||||||
super(Opcodes.ASM7, classVisitor);
|
super(Opcodes.ASM7, classVisitor);
|
||||||
this.project = project
|
this.project = project
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
|
||||||
|
this.name = name
|
||||||
|
super.visit(version, access, name, signature, superName, interfaces)
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||||
if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;") {
|
if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/Isolated;") {
|
||||||
|
return new IsolatedAnnotationVisitor(super.visitAnnotation(descriptor, visible), project, name, this)
|
||||||
|
} else if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;") {
|
||||||
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||||
} else {
|
} else {
|
||||||
return super.visitAnnotation(descriptor, visible)
|
return super.visitAnnotation(descriptor, visible)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void visitEnd() {
|
||||||
|
super.visitEnd()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ class TabooLibPlugin implements Plugin<Project> {
|
||||||
task.inJar = task.inJar ?: jarTask.archivePath
|
task.inJar = task.inJar ?: jarTask.archivePath
|
||||||
task.relocations = tabooExt.relocation
|
task.relocations = tabooExt.relocation
|
||||||
task.classifier = tabooExt.classifier
|
task.classifier = tabooExt.classifier
|
||||||
task.relocations['taboolib'] = task.relocations['taboolib'] ?: project.group.toString() + '.taboolib'
|
task.relocations['taboolib'] = project.group.toString() + '.taboolib'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue