From b386e38bf2d2f53d2df921493de4c3fab18ec247 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Nov 2024 21:19:03 +0000 Subject: [PATCH 1/3] refactor: Replace Plexus AbstractLogEnabled with SLF4J Use this link to re-run the recipe: https://app.moderne.io/builder/P4zH7djn6?organizationId=QXBhY2hlIE1hdmVu Co-authored-by: Moderne --- .../plugins/javadoc/resolver/ResourceResolver.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java b/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java index 53cf3b280..9553e2491 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java @@ -54,7 +54,6 @@ import org.codehaus.plexus.archiver.UnArchiver; import org.codehaus.plexus.archiver.manager.ArchiverManager; import org.codehaus.plexus.archiver.manager.NoSuchArchiverException; -import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; @@ -62,13 +61,16 @@ import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.resolution.ArtifactRequest; import org.eclipse.aether.resolution.ArtifactResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * */ @Named @Singleton -public final class ResourceResolver extends AbstractLogEnabled { +public final class ResourceResolver { + private static final Logger logger = LoggerFactory.getLogger(ResourceResolver.class); @Inject private RepositorySystem repoSystem; @@ -220,8 +222,8 @@ private List resolveBundlesFromArtifacts( try { dirs = resolveAndUnpack(toResolve, config, RESOURCE_VALID_CLASSIFIERS, false); } catch (ArtifactResolutionException | ArtifactNotFoundException e) { - if (getLogger().isDebugEnabled()) { - getLogger().debug(e.getMessage(), e); + if (logger.isDebugEnabled()) { + logger.debug(e.getMessage(), e); } } From 9c6680ba25ec1ce00fefde8513dbd2999d30ae18 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Nov 2024 22:35:08 +0100 Subject: [PATCH 2/3] Move `slf4j-api` to compile scope now that we no longer log using Plexus --- pom.xml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index eaf71e68a..ea1c614bc 100644 --- a/pom.xml +++ b/pom.xml @@ -286,6 +286,12 @@ under the License. 2.1.0 + + org.slf4j + slf4j-api + ${slf4jVersion} + + org.codehaus.plexus @@ -403,12 +409,6 @@ under the License. 3.26.3 test - - org.slf4j - slf4j-api - ${slf4jVersion} - test - org.slf4j slf4j-simple From 8f12132d2238c5dcef430aca1005bafeb8482e66 Mon Sep 17 00:00:00 2001 From: Tim te Beek Date: Sat, 16 Nov 2024 22:36:29 +0100 Subject: [PATCH 3/3] Fix checkstyle violation --- .../maven/plugins/javadoc/resolver/ResourceResolver.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java b/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java index 9553e2491..51d814b7b 100644 --- a/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java +++ b/src/main/java/org/apache/maven/plugins/javadoc/resolver/ResourceResolver.java @@ -70,7 +70,8 @@ @Named @Singleton public final class ResourceResolver { - private static final Logger logger = LoggerFactory.getLogger(ResourceResolver.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ResourceResolver.class); + @Inject private RepositorySystem repoSystem; @@ -222,8 +223,8 @@ private List resolveBundlesFromArtifacts( try { dirs = resolveAndUnpack(toResolve, config, RESOURCE_VALID_CLASSIFIERS, false); } catch (ArtifactResolutionException | ArtifactNotFoundException e) { - if (logger.isDebugEnabled()) { - logger.debug(e.getMessage(), e); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug(e.getMessage(), e); } }