This is an automated email from the ASF dual-hosted git repository. cstamas pushed a commit to branch drop-commons-io in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git
commit 0858472d521370b8e5a73b4f3241868305fc21a2 Author: Tamas Cservenak <[email protected]> AuthorDate: Thu Feb 26 20:46:05 2026 +0100 Drop commons-io --- pom.xml | 26 +--------------------- .../resource/ServiceResourceTransformerTest.java | 22 +++++++++++++----- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/pom.xml b/pom.xml index 7ad0742..c6ed286 100644 --- a/pom.xml +++ b/pom.xml @@ -160,18 +160,6 @@ </dependency> <!-- Test --> - <!-- Used by: TransformerTesterRule only --> - <dependency> - <groupId>org.eclipse.sisu</groupId> - <artifactId>org.eclipse.sisu.plexus</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>com.google.inject</groupId> - <artifactId>guice</artifactId> - <version>5.1.0</version> - <scope>test</scope> - </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> @@ -180,7 +168,7 @@ </dependency> <dependency> <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> + <artifactId>hamcrest</artifactId> <version>3.0</version> <scope>test</scope> </dependency> @@ -202,24 +190,12 @@ <version>${slf4j.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-compat</artifactId> - <version>${mavenVersion}</version> - <scope>test</scope> - </dependency> <dependency> <groupId>org.apache.maven.plugin-testing</groupId> <artifactId>maven-plugin-testing-harness</artifactId> <version>3.5.1</version> <scope>test</scope> </dependency> - <dependency> - <groupId>commons-io</groupId> - <artifactId>commons-io</artifactId> - <version>2.21.0</version> - <scope>test</scope> - </dependency> </dependencies> <build> diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java index dd0e80e..e468c5b 100644 --- a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java @@ -19,9 +19,12 @@ package org.apache.maven.plugins.shade.resource; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; +import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -31,7 +34,6 @@ import java.util.jar.JarEntry; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; -import org.apache.commons.io.IOUtils; import org.apache.maven.plugins.shade.relocation.Relocator; import org.apache.maven.plugins.shade.relocation.SimpleRelocator; import org.junit.Test; @@ -75,7 +77,7 @@ public class ServiceResourceTransformerTest { JarEntry jarEntry = jarFile.getJarEntry(contentResourceShaded); assertNotNull(jarEntry); try (InputStream entryStream = jarFile.getInputStream(jarEntry)) { - String xformedContent = IOUtils.toString(entryStream, "utf-8"); + String xformedContent = toString(entryStream, StandardCharsets.UTF_8); assertEquals("borg.foo.Service" + newline + "org.foo.exclude.OtherService" + newline, xformedContent); } finally { jarFile.close(); @@ -118,7 +120,7 @@ public class ServiceResourceTransformerTest { JarEntry jarEntry = jarFile.getJarEntry(contentResourceShaded); assertNotNull(jarEntry); try (InputStream entryStream = jarFile.getInputStream(jarEntry)) { - String xformedContent = IOUtils.toString(entryStream, StandardCharsets.UTF_8); + String xformedContent = toString(entryStream, StandardCharsets.UTF_8); assertEquals(contentShaded, xformedContent); } finally { jarFile.close(); @@ -153,7 +155,7 @@ public class ServiceResourceTransformerTest { JarEntry jarEntry = jarFile.getJarEntry(contentResource); assertNotNull(jarEntry); try (InputStream entryStream = jarFile.getInputStream(jarEntry)) { - String xformedContent = IOUtils.toString(entryStream, StandardCharsets.UTF_8); + String xformedContent = toString(entryStream, StandardCharsets.UTF_8); assertEquals("org.eclipse1234.osgi.launch.EquinoxFactory" + newline, xformedContent); } finally { jarFile.close(); @@ -196,7 +198,7 @@ public class ServiceResourceTransformerTest { JarEntry jarEntry = jarFile.getJarEntry(contentResource); assertNotNull(jarEntry); try (InputStream entryStream = jarFile.getInputStream(jarEntry)) { - String xformedContent = IOUtils.toString(entryStream, "utf-8"); + String xformedContent = toString(entryStream, StandardCharsets.UTF_8); // must be two lines, with our two classes. String[] classes = xformedContent.split("\r?\n"); boolean h1 = false; @@ -216,4 +218,14 @@ public class ServiceResourceTransformerTest { tempJar.delete(); } } + + private static String toString(InputStream stream, Charset charset) throws IOException { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + byte[] data = new byte[8192]; + int read; + while ((read = stream.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, read); + } + return new String(buffer.toByteArray(), charset); + } }
