From 15690f0d0bb8d573e49a930cc29245691d484386 Mon Sep 17 00:00:00 2001 From: Goooler Date: Mon, 5 Aug 2024 14:54:35 +0800 Subject: [PATCH] Log ignored exceptions --- .../gradle/plugins/shadow/tasks/ShadowCopyAction.groovy | 4 ++-- .../shadow/transformers/ManifestAppenderTransformer.groovy | 5 ++++- .../shadow/transformers/ManifestResourceTransformer.groovy | 5 ++++- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy index d0a394698..2914638af 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/tasks/ShadowCopyAction.groovy @@ -153,8 +153,8 @@ class ShadowCopyAction implements CopyAction { } catch(Throwable t) { try { resource.close() - } catch (IOException ignored) { - // Ignored + } catch (IOException e) { + log.warn("Could not close resource $resource", e) } throw UncheckedException.throwAsUncheckedException(t) } diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.groovy index 49fec43e7..bff6601d5 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestAppenderTransformer.groovy @@ -19,6 +19,7 @@ package com.github.jengelman.gradle.plugins.shadow.transformers +import groovy.util.logging.Slf4j import org.apache.tools.zip.ZipEntry import org.apache.tools.zip.ZipOutputStream import org.codehaus.plexus.util.IOUtil @@ -36,6 +37,7 @@ import static java.util.jar.JarFile.MANIFEST_NAME * Modified from {@link ManifestResourceTransformer}. * @author Chris Rankin */ +@Slf4j class ManifestAppenderTransformer implements Transformer { private static final byte[] EOL = "\r\n".getBytes(UTF_8) private static final byte[] SEPARATOR = ": ".getBytes(UTF_8) @@ -62,7 +64,8 @@ class ManifestAppenderTransformer implements Transformer { manifestContents = IOUtil.toByteArray(context.is) try { context.is - } catch (IOException ignored) { + } catch (IOException e) { + log.warn("Failed to read MANIFEST.MF", e) } } } diff --git a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.groovy b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.groovy index 1888bc0b1..8232b7fea 100644 --- a/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.groovy +++ b/src/main/groovy/com/github/jengelman/gradle/plugins/shadow/transformers/ManifestResourceTransformer.groovy @@ -19,6 +19,7 @@ package com.github.jengelman.gradle.plugins.shadow.transformers +import groovy.util.logging.Slf4j import org.apache.tools.zip.ZipEntry import org.apache.tools.zip.ZipOutputStream import org.gradle.api.file.FileTreeElement @@ -39,6 +40,7 @@ import java.util.jar.Manifest * @author Jason van Zyl * @author John Engelman */ +@Slf4j class ManifestResourceTransformer implements Transformer { // Configuration @@ -73,7 +75,8 @@ class ManifestResourceTransformer implements Transformer { manifestDiscovered = true try { context.is - } catch (IOException ignored) { + } catch (IOException e) { + log.warn("Failed to read MANIFEST.MF", e) } } }