1.5
This commit is contained in:
parent
81f9cfdc42
commit
84ef9b98db
10
build.gradle
10
build.gradle
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'io.izzel.taboolib'
|
group 'io.izzel.taboolib'
|
||||||
version '1.4'
|
version '1.5'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
embed
|
embed
|
||||||
|
|
@ -45,3 +45,11 @@ gradlePlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = file("/Users/sky/Desktop/repo")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@ package io.izzel.taboolib.gradle
|
||||||
|
|
||||||
import groovy.transform.ToString
|
import groovy.transform.ToString
|
||||||
import org.gradle.api.DefaultTask
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.tasks.Input
|
import org.gradle.api.tasks.Input
|
||||||
import org.gradle.api.tasks.InputFile
|
import org.gradle.api.tasks.InputFile
|
||||||
import org.gradle.api.tasks.Optional
|
import org.gradle.api.tasks.Optional
|
||||||
|
|
@ -29,6 +30,9 @@ class RelocateJar extends DefaultTask {
|
||||||
@Input
|
@Input
|
||||||
String classifier
|
String classifier
|
||||||
|
|
||||||
|
@Input
|
||||||
|
Project project
|
||||||
|
|
||||||
@TaskAction
|
@TaskAction
|
||||||
def relocate() {
|
def relocate() {
|
||||||
def mapping = relocations.collectEntries { [(it.key.replace('.', '/')), it.value.replace('.', '/')] }
|
def mapping = relocations.collectEntries { [(it.key.replace('.', '/')), it.value.replace('.', '/')] }
|
||||||
|
|
@ -48,7 +52,7 @@ class RelocateJar extends DefaultTask {
|
||||||
project.logger.info("Relocating " + jarEntry.name)
|
project.logger.info("Relocating " + jarEntry.name)
|
||||||
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)
|
def visitor = new TabooLibClassVisitor(writer, project)
|
||||||
reader.accept(new ClassRemapper(visitor, remapper), 0)
|
reader.accept(new ClassRemapper(visitor, remapper), 0)
|
||||||
out.putNextEntry(new JarEntry(remapper.map(jarEntry.name)))
|
out.putNextEntry(new JarEntry(remapper.map(jarEntry.name)))
|
||||||
out.write(writer.toByteArray())
|
out.write(writer.toByteArray())
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,9 @@ class SpongeAnnotationVisitor extends AnnotationVisitor {
|
||||||
|
|
||||||
Project project
|
Project project
|
||||||
|
|
||||||
SpongeAnnotationVisitor(AnnotationVisitor annotationVisitor) {
|
SpongeAnnotationVisitor(AnnotationVisitor annotationVisitor, project) {
|
||||||
super(Opcodes.ASM5, annotationVisitor)
|
super(Opcodes.ASM7, annotationVisitor)
|
||||||
|
this.project = project
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
package io.izzel.taboolib.gradle
|
package io.izzel.taboolib.gradle
|
||||||
|
|
||||||
|
import org.gradle.api.Project
|
||||||
import org.objectweb.asm.AnnotationVisitor
|
import org.objectweb.asm.AnnotationVisitor
|
||||||
import org.objectweb.asm.ClassVisitor
|
import org.objectweb.asm.ClassVisitor
|
||||||
import org.objectweb.asm.Opcodes
|
import org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
class TabooLibClassVisitor extends ClassVisitor {
|
class TabooLibClassVisitor extends ClassVisitor {
|
||||||
|
|
||||||
TabooLibClassVisitor(ClassVisitor classVisitor) {
|
Project project
|
||||||
super(Opcodes.ASM5, classVisitor);
|
|
||||||
|
TabooLibClassVisitor(ClassVisitor classVisitor, Project project) {
|
||||||
|
super(Opcodes.ASM7, classVisitor);
|
||||||
|
this.project = project
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||||
if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;") {
|
if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;") {
|
||||||
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible))
|
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||||
} else {
|
} else {
|
||||||
return super.visitAnnotation(descriptor, visible)
|
return super.visitAnnotation(descriptor, visible)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,17 +8,16 @@ class TabooLibPlugin implements Plugin<Project> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void apply(Project project) {
|
void apply(Project project) {
|
||||||
project.repositories.maven { url URI("https://repo2s.ptms.ink/repository/maven-releases/") }
|
project.repositories.maven { url project.uri("https://repo2s.ptms.ink/repository/maven-releases/") }
|
||||||
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)
|
||||||
tabooTask.project = project
|
|
||||||
|
|
||||||
project.afterEvaluate {
|
project.afterEvaluate {
|
||||||
project.configurations.compileClasspath.extendsFrom(taboo)
|
project.configurations.compileClasspath.extendsFrom(taboo)
|
||||||
// subprojects
|
// subprojects
|
||||||
tabooExt.modules.each {
|
tabooExt.modules.each {
|
||||||
project.configurations.compileClasspath.dependencies.add(project.dependencies.create("io.izzel:taboolib:${tabooExt.version}:${it}"))
|
project.configurations.taboo.dependencies.add(project.dependencies.create("io.izzel:taboolib:${tabooExt.version}:${it}"))
|
||||||
}
|
}
|
||||||
project.tasks.jar.finalizedBy(tabooTask)
|
project.tasks.jar.finalizedBy(tabooTask)
|
||||||
project.tasks.jar.configure { Jar task ->
|
project.tasks.jar.configure { Jar task ->
|
||||||
|
|
@ -26,6 +25,7 @@ class TabooLibPlugin implements Plugin<Project> {
|
||||||
}
|
}
|
||||||
def jarTask = project.tasks.jar as Jar
|
def jarTask = project.tasks.jar as Jar
|
||||||
tabooTask.configure { RelocateJar task ->
|
tabooTask.configure { RelocateJar task ->
|
||||||
|
task.project = 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
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue