1.9
This commit is contained in:
parent
3dcbff0684
commit
aeff5b4ad4
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'io.izzel.taboolib'
|
group 'io.izzel.taboolib'
|
||||||
version '1.8'
|
version '1.9'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
embed
|
embed
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,55 @@
|
||||||
|
package io.izzel.taboolib.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.objectweb.asm.AnnotationVisitor
|
||||||
|
import org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
|
class KotlinAnnotationVisitor extends AnnotationVisitor {
|
||||||
|
|
||||||
|
Project project
|
||||||
|
|
||||||
|
KotlinAnnotationVisitor(AnnotationVisitor annotationVisitor, project) {
|
||||||
|
super(Opcodes.ASM7, annotationVisitor)
|
||||||
|
this.project = project
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void visit(String name, Object value) {
|
||||||
|
if (value instanceof String) {
|
||||||
|
super.visit(name, value
|
||||||
|
.replace("@kotlin_version@", getKotlinVersion())
|
||||||
|
.replace("@kotlin_version_escape@", getKotlinVersionEscape())
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
super.visit(name, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void visitEnum(String name, String descriptor, String value) {
|
||||||
|
super.visitEnum(name, descriptor, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
AnnotationVisitor visitAnnotation(String name, String descriptor) {
|
||||||
|
return new KotlinAnnotationVisitor(super.visitAnnotation(name, descriptor), project)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
AnnotationVisitor visitArray(String name) {
|
||||||
|
return new KotlinAnnotationVisitor(super.visitArray(name), project)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void visitEnd() {
|
||||||
|
super.visitEnd()
|
||||||
|
}
|
||||||
|
|
||||||
|
String getKotlinVersion() {
|
||||||
|
return project.plugins.findPlugin("org.jetbrains.kotlin.jvm").kotlinPluginVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
String getKotlinVersionEscape() {
|
||||||
|
return getKotlinVersion().replaceAll("[.-]", "_")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -32,6 +32,10 @@ class TabooLibClassVisitor extends ClassVisitor {
|
||||||
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||||
if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/Isolated;") {
|
if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/Isolated;") {
|
||||||
return new IsolatedAnnotationVisitor(super.visitAnnotation(descriptor, visible), project, name, this)
|
return new IsolatedAnnotationVisitor(super.visitAnnotation(descriptor, visible), project, name, this)
|
||||||
|
} else if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/env/RuntimeDependency;") {
|
||||||
|
return new KotlinAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||||
|
} else if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/env/RuntimeDependencies;") {
|
||||||
|
return new KotlinAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||||
} else if (descriptor in annotations) {
|
} else if (descriptor in annotations) {
|
||||||
return new PluginAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
return new PluginAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ class TabooLibPlugin implements Plugin<Project> {
|
||||||
def tabooExt = project.extensions.create('taboolib', TabooLibExtension)
|
def tabooExt = project.extensions.create('taboolib', TabooLibExtension)
|
||||||
def taboo = project.configurations.maybeCreate('taboo')
|
def taboo = project.configurations.maybeCreate('taboo')
|
||||||
def tabooTask = project.tasks.create('tabooRelocateJar', RelocateJar)
|
def tabooTask = project.tasks.create('tabooRelocateJar', RelocateJar)
|
||||||
|
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
project.configurations.compileClasspath.extendsFrom(taboo)
|
project.configurations.compileClasspath.extendsFrom(taboo)
|
||||||
// subprojects
|
// subprojects
|
||||||
|
|
@ -23,6 +22,7 @@ class TabooLibPlugin implements Plugin<Project> {
|
||||||
project.tasks.jar.configure { Jar task ->
|
project.tasks.jar.configure { Jar task ->
|
||||||
task.from(taboo.collect { it.isDirectory() ? it : project.zipTree(it) })
|
task.from(taboo.collect { it.isDirectory() ? it : project.zipTree(it) })
|
||||||
}
|
}
|
||||||
|
def kv = project.plugins.findPlugin("org.jetbrains.kotlin.jvm").kotlinPluginVersion.replaceAll("[.-]", "_")
|
||||||
def jarTask = project.tasks.jar as Jar
|
def jarTask = project.tasks.jar as Jar
|
||||||
tabooTask.configure { RelocateJar task ->
|
tabooTask.configure { RelocateJar task ->
|
||||||
task.tabooExt = tabooExt
|
task.tabooExt = tabooExt
|
||||||
|
|
@ -30,6 +30,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['kotlin'] = 'taboolib.library.kotlin_' + kv
|
||||||
task.relocations['taboolib'] = project.group.toString() + '.taboolib'
|
task.relocations['taboolib'] = project.group.toString() + '.taboolib'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue