diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/RelocationUtil.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/RelocationUtil.groovy deleted file mode 100644 index f94ab89ed..000000000 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/RelocationUtil.groovy +++ /dev/null @@ -1,25 +0,0 @@ -package com.github.jengelman.gradle.plugins.shadow.internal - -import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar -import java.util.jar.JarFile - -class RelocationUtil { - - static void configureRelocation(ShadowJar target, String prefix) { - def packages = [] as Set - target.configurations.each { configuration -> - configuration.files.each { jar -> - JarFile jf = new JarFile(jar) - jf.entries().each { entry -> - if (entry.name.endsWith(".class") && entry.name != "module-info.class") { - packages << entry.name[0..entry.name.lastIndexOf('/') - 1].replaceAll('/', '.') - } - } - jf.close() - } - } - packages.each { - target.relocate(it, "${prefix}.${it}") - } - } -} diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/GradleVersionUtil.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/Utils.groovy similarity index 55% rename from src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/GradleVersionUtil.groovy rename to src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/Utils.groovy index 3bc6f0563..c4abb21fe 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/GradleVersionUtil.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/internal/Utils.groovy @@ -1,12 +1,15 @@ package com.github.jengelman.gradle.plugins.shadow.internal +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import org.apache.tools.zip.ZipOutputStream import org.gradle.api.internal.file.copy.CopySpecInternal import org.gradle.api.tasks.bundling.Jar import org.gradle.api.tasks.bundling.ZipEntryCompression import org.gradle.api.tasks.util.PatternSet -class GradleVersionUtil { +import java.util.jar.JarFile + +class Utils { static PatternSet getRootPatternSet(CopySpecInternal mainSpec) { return mainSpec.buildRootResolver().getPatternSet() @@ -22,4 +25,22 @@ class GradleVersionUtil { throw new IllegalArgumentException(String.format("Unknown Compression type %s", entryCompression)) } } + + static void configureRelocation(ShadowJar target, String prefix) { + def packages = [] as Set + target.configurations.each { configuration -> + configuration.files.each { jar -> + JarFile jf = new JarFile(jar) + jf.entries().each { entry -> + if (entry.name.endsWith(".class") && entry.name != "module-info.class") { + packages << entry.name[0..entry.name.lastIndexOf('/') - 1].replaceAll('/', '.') + } + } + jf.close() + } + } + packages.each { + target.relocate(it, "${prefix}.${it}") + } + } } diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java index 88b48c3ab..b391cb9cb 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowJar.java @@ -151,14 +151,14 @@ FileCollection getSourceSetsClassesDirs() { @Internal protected ZipCompressor getInternalCompressor() { - return GradleVersionUtil.getInternalCompressor(getEntryCompression(), this); + return Utils.getInternalCompressor(getEntryCompression(), this); } @TaskAction @Override protected void copy() { if (enableRelocation) { - RelocationUtil.configureRelocation(this, relocationPrefix); + Utils.configureRelocation(this, relocationPrefix); } from(getIncludedDependencies()); super.copy(); @@ -177,7 +177,7 @@ public FileCollection getIncludedDependencies() { */ @Internal protected PatternSet getRootPatternSet() { - return GradleVersionUtil.getRootPatternSet(getMainSpec()); + return Utils.getRootPatternSet(getMainSpec()); } /**