1.5 test minimize
This commit is contained in:
parent
84ef9b98db
commit
4e8d42f4b9
|
|
@ -6,7 +6,7 @@ plugins {
|
|||
}
|
||||
|
||||
group 'io.izzel.taboolib'
|
||||
version '1.5'
|
||||
version '1.6'
|
||||
|
||||
configurations {
|
||||
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 outJar = new File(inJar.getParentFile(), name)
|
||||
def tmpOut = File.createTempFile(name, ".jar")
|
||||
def isolated = new HashMap<String, List<String>>()
|
||||
new JarOutputStream(new FileOutputStream(tmpOut)).withCloseable { out ->
|
||||
project.logger.info(outJar.getAbsolutePath())
|
||||
int n
|
||||
|
|
@ -54,6 +55,7 @@ class RelocateJar extends DefaultTask {
|
|||
def writer = new ClassWriter(0)
|
||||
def visitor = new TabooLibClassVisitor(writer, project)
|
||||
reader.accept(new ClassRemapper(visitor, remapper), 0)
|
||||
isolated.putAll(visitor.isolated)
|
||||
out.putNextEntry(new JarEntry(remapper.map(jarEntry.name)))
|
||||
out.write(writer.toByteArray())
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -7,19 +7,34 @@ import org.objectweb.asm.Opcodes
|
|||
|
||||
class TabooLibClassVisitor extends ClassVisitor {
|
||||
|
||||
String name
|
||||
Project project
|
||||
Map<String, List<String>> isolated = new HashMap()
|
||||
|
||||
TabooLibClassVisitor(ClassVisitor classVisitor, Project project) {
|
||||
super(Opcodes.ASM7, classVisitor);
|
||||
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
|
||||
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)
|
||||
} else {
|
||||
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.relocations = tabooExt.relocation
|
||||
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