Skip to content

Commit

Permalink
Merge pull request #128 from nebula-plugins/applyRecommendationToDepe…
Browse files Browse the repository at this point in the history
…ndency-disable-deprecation

applyRecommendationToDependency: disable deprecation logging for now
  • Loading branch information
rpalcolea authored Oct 8, 2024
2 parents d09693d + b1552b0 commit 39ff33a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ gradlePlugin {
*/
tasks.withType(Test).configureEach {
Provider<String> 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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 39ff33a

Please sign in to comment.