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'
|
||||
version '1.4'
|
||||
version '1.5'
|
||||
|
||||
configurations {
|
||||
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 org.gradle.api.DefaultTask
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.tasks.Input
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.Optional
|
||||
|
|
@ -29,6 +30,9 @@ class RelocateJar extends DefaultTask {
|
|||
@Input
|
||||
String classifier
|
||||
|
||||
@Input
|
||||
Project project
|
||||
|
||||
@TaskAction
|
||||
def relocate() {
|
||||
def mapping = relocations.collectEntries { [(it.key.replace('.', '/')), it.value.replace('.', '/')] }
|
||||
|
|
@ -48,7 +52,7 @@ class RelocateJar extends DefaultTask {
|
|||
project.logger.info("Relocating " + jarEntry.name)
|
||||
def reader = new ClassReader(it)
|
||||
def writer = new ClassWriter(0)
|
||||
def visitor = new TabooLibClassVisitor(writer)
|
||||
def visitor = new TabooLibClassVisitor(writer, project)
|
||||
reader.accept(new ClassRemapper(visitor, remapper), 0)
|
||||
out.putNextEntry(new JarEntry(remapper.map(jarEntry.name)))
|
||||
out.write(writer.toByteArray())
|
||||
|
|
|
|||
|
|
@ -8,8 +8,9 @@ class SpongeAnnotationVisitor extends AnnotationVisitor {
|
|||
|
||||
Project project
|
||||
|
||||
SpongeAnnotationVisitor(AnnotationVisitor annotationVisitor) {
|
||||
super(Opcodes.ASM5, annotationVisitor)
|
||||
SpongeAnnotationVisitor(AnnotationVisitor annotationVisitor, project) {
|
||||
super(Opcodes.ASM7, annotationVisitor)
|
||||
this.project = project
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -1,19 +1,23 @@
|
|||
package io.izzel.taboolib.gradle
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.objectweb.asm.AnnotationVisitor
|
||||
import org.objectweb.asm.ClassVisitor
|
||||
import org.objectweb.asm.Opcodes
|
||||
|
||||
class TabooLibClassVisitor extends ClassVisitor {
|
||||
|
||||
TabooLibClassVisitor(ClassVisitor classVisitor) {
|
||||
super(Opcodes.ASM5, classVisitor);
|
||||
Project project
|
||||
|
||||
TabooLibClassVisitor(ClassVisitor classVisitor, Project project) {
|
||||
super(Opcodes.ASM7, classVisitor);
|
||||
this.project = project
|
||||
}
|
||||
|
||||
@Override
|
||||
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||
if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;") {
|
||||
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible))
|
||||
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||
} else {
|
||||
return super.visitAnnotation(descriptor, visible)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,16 @@ class TabooLibPlugin implements Plugin<Project> {
|
|||
|
||||
@Override
|
||||
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 taboo = project.configurations.maybeCreate('taboo')
|
||||
def tabooTask = project.tasks.create('tabooRelocateJar', RelocateJar)
|
||||
tabooTask.project = project
|
||||
|
||||
project.afterEvaluate {
|
||||
project.configurations.compileClasspath.extendsFrom(taboo)
|
||||
// subprojects
|
||||
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.configure { Jar task ->
|
||||
|
|
@ -26,6 +25,7 @@ class TabooLibPlugin implements Plugin<Project> {
|
|||
}
|
||||
def jarTask = project.tasks.jar as Jar
|
||||
tabooTask.configure { RelocateJar task ->
|
||||
task.project = project
|
||||
task.inJar = task.inJar ?: jarTask.archivePath
|
||||
task.relocations = tabooExt.relocation
|
||||
task.classifier = tabooExt.classifier
|
||||
|
|
|
|||
Loading…
Reference in New Issue