From b1552b07420ae396d5d5783692f90109220cdddb Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Tue, 8 Oct 2024 14:40:07 -0700 Subject: [PATCH] applyRecommendationToDependency: disable deprecation logging for now --- build.gradle | 2 +- .../recommender/DependencyRecommendationsPlugin.java | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index 9384952..e4537f2 100644 --- a/build.gradle +++ b/build.gradle @@ -54,7 +54,7 @@ gradlePlugin { */ tasks.withType(Test).configureEach { Provider jdkVersionForTestsEnvVariable = providers.environmentVariable("JDK_VERSION_FOR_TESTS") - Integer jdkVersionForTests = jdkVersionForTestsEnvVariable.isPresent() ? jdkVersionForTestsEnvVariable.get().toInteger() : 8 + Integer jdkVersionForTests = jdkVersionForTestsEnvVariable.isPresent() ? jdkVersionForTestsEnvVariable.get().toInteger() : 17 if(jdkVersionForTests >= 17) { jvmArgs = [ '--add-opens=java.base/java.lang=ALL-UNNAMED', diff --git a/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java b/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java index 1852bc0..6a4ce39 100644 --- a/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java +++ b/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java @@ -38,6 +38,7 @@ import org.gradle.api.logging.Logger; import org.gradle.api.logging.Logging; import org.gradle.api.plugins.ExtraPropertiesExtension; +import org.gradle.internal.deprecation.DeprecationLogger; import java.lang.reflect.Method; import java.util.*; @@ -166,20 +167,23 @@ private void applyRecommendationToDependency(final RecommendationStrategyFactory ProjectDependency projectDependency = (ProjectDependency) dependency; if (!visited.contains(projectDependency)) { visited.add(projectDependency); - Configuration configuration; + final Configuration[] configuration = new Configuration[1]; try { ProjectDependency.class.getMethod("getTargetConfiguration"); String targetConfiguration = projectDependency.getTargetConfiguration() == null ? Dependency.DEFAULT_CONFIGURATION : projectDependency.getTargetConfiguration(); - configuration = projectDependency.getDependencyProject().getConfigurations().getByName(targetConfiguration); + + DeprecationLogger.whileDisabled(() -> { + configuration[0] = projectDependency.getDependencyProject().getConfigurations().getByName(targetConfiguration); + }); } catch (NoSuchMethodException ignore) { try { Method method = ProjectDependency.class.getMethod("getProjectConfiguration"); - configuration = (Configuration) method.invoke(dependency); + configuration[0] = (Configuration) method.invoke(dependency); } catch (Exception e) { throw new RuntimeException("Unable to retrieve configuration for project dependency", e); } } - DependencySet dependencies = configuration.getAllDependencies(); + DependencySet dependencies = configuration[0].getAllDependencies(); for (Dependency dep : dependencies) { applyRecommendationToDependency(factory, dep, visited); }