From 943f2679f984f027e9f13450c889cd0540a81787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=9D=8F=E9=BB=91?= Date: Mon, 2 Aug 2021 15:15:27 +0800 Subject: [PATCH] 1.13 --- build.gradle | 2 +- .../izzel/taboolib/gradle/RelocateJar.groovy | 53 ++++++++++--------- .../taboolib/gradle/TabooLibExtension.groovy | 6 +++ 3 files changed, 35 insertions(+), 26 deletions(-) diff --git a/build.gradle b/build.gradle index 2aa0715..aa8664f 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,7 @@ plugins { } group 'io.izzel.taboolib' -version '1.12' +version '1.13' configurations { embed diff --git a/src/main/groovy/io/izzel/taboolib/gradle/RelocateJar.groovy b/src/main/groovy/io/izzel/taboolib/gradle/RelocateJar.groovy index 07a2c15..bf0acd8 100644 --- a/src/main/groovy/io/izzel/taboolib/gradle/RelocateJar.groovy +++ b/src/main/groovy/io/izzel/taboolib/gradle/RelocateJar.groovy @@ -53,32 +53,35 @@ class RelocateJar extends DefaultTask { def buf = new byte[32768] new JarFile(inJar).withCloseable { jarFile -> jarFile.entries().each { def jarEntry -> - jarFile.getInputStream(jarEntry).withCloseable { - if (jarEntry.name.endsWith(".class")) { - def reader = new ClassReader(it) - def writer = new ClassWriter(0) - def visitor = new TabooLibClassVisitor(writer, project) - def rem = new ClassRemapper(visitor, remapper) - remapper.remapper = rem - reader.accept(rem, 0) - isolated.putAll(visitor.isolated) - try { - out.putNextEntry(new JarEntry(remapper.map(jarEntry.name))) - } catch(ZipException zipException) { - println(zipException) - return true - } - out.write(writer.toByteArray()) - } else { - try { - out.putNextEntry(new JarEntry(remapper.map(jarEntry.name))) - } catch(ZipException zipException) { - println(zipException) - return true - } - while ((n = it.read(buf)) != -1) { - out.write(buf, 0, n) + if (tabooExt.exclude.none { String e -> jarEntry.name.matches(e) }) { + jarFile.getInputStream(jarEntry).withCloseable { + if (jarEntry.name.endsWith(".class")) { + def reader = new ClassReader(it) + def writer = new ClassWriter(0) + def visitor = new TabooLibClassVisitor(writer, project) + def rem = new ClassRemapper(visitor, remapper) + remapper.remapper = rem + reader.accept(rem, 0) + isolated.putAll(visitor.isolated) + try { + out.putNextEntry(new JarEntry(remapper.map(jarEntry.name))) + } catch(ZipException zipException) { + println(zipException) + return true + } + out.write(writer.toByteArray()) + } else { + try { + out.putNextEntry(new JarEntry(remapper.map(jarEntry.name))) + } catch(ZipException ex) { + println(ex) + return true + } + while ((n = it.read(buf)) != -1) { + out.write(buf, 0, n) + } } + null } } } diff --git a/src/main/groovy/io/izzel/taboolib/gradle/TabooLibExtension.groovy b/src/main/groovy/io/izzel/taboolib/gradle/TabooLibExtension.groovy index a568441..daf274c 100644 --- a/src/main/groovy/io/izzel/taboolib/gradle/TabooLibExtension.groovy +++ b/src/main/groovy/io/izzel/taboolib/gradle/TabooLibExtension.groovy @@ -13,6 +13,8 @@ class TabooLibExtension { List modules = [] + List exclude = [] + Description des = new Description() Map relocation = new LinkedHashMap<>() @@ -21,6 +23,10 @@ class TabooLibExtension { name.each { modules += it } } + def exclude(String match) { + exclude += match + } + def relocate(String pre, String post) { relocation[pre] = post }