From 4ca202172340c80b1c4d968e40c9ba6899f7e615 Mon Sep 17 00:00:00 2001 From: Roberto Perez Alcolea Date: Fri, 11 Oct 2019 16:31:41 -0700 Subject: [PATCH] make sure we do not apply recommendations for provided versions by gradle --- .../DependencyRecommendationsPlugin.java | 2 + ...DependencyRecommendationsPluginSpec.groovy | 47 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java b/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java index 494d91d..3b7ca5e 100644 --- a/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java +++ b/src/main/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPlugin.java @@ -64,6 +64,8 @@ public void apply(final Project project) { recommendationProviderContainer.excludeConfigurationPrefixes(SCALA_ANALYSIS_CONFIGURATION_PREFIX, "spotbugs", "findbugs"); applyRecommendationsDirectly(project, bomConfiguration); } else { + recommendationProviderContainer.excludeConfigurations("zinc", "checkstyle", "jacocoAgent", "jacocoAnt"); + recommendationProviderContainer.excludeConfigurationPrefixes(SCALA_ANALYSIS_CONFIGURATION_PREFIX, "spotbugs", "findbugs"); applyRecommendations(project); enhanceDependenciesWithRecommender(project); } diff --git a/src/test/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPluginSpec.groovy b/src/test/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPluginSpec.groovy index c89a02c..849740c 100644 --- a/src/test/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPluginSpec.groovy +++ b/src/test/groovy/netflix/nebula/dependency/recommender/DependencyRecommendationsPluginSpec.groovy @@ -92,6 +92,53 @@ class DependencyRecommendationsPluginSpec extends IntegrationSpec { result.standardOutput.contains 'test.nebula:foo -> 1.0.0' } + def 'provide recommendation via configuration - no zinc'() { + def repo = new MavenRepo() + repo.root = new File(projectDir, 'build/bomrepo') + def pom = new Pom('test.nebula.bom', 'testbom', '2.0.0', ArtifactType.POM) + pom.addManagementDependency('test.nebula', 'foo', '2.0.0') + repo.poms.add(pom) + repo.generate() + def graph = new DependencyGraphBuilder() + .addModule('test.nebula:foo:1.0.0') + .addModule('test.nebula:foo:2.0.0') + .build() + def generator = new GradleDependencyGenerator(graph) + generator.generateTestMavenRepo() + + buildFile << """\ + apply plugin: 'nebula.dependency-recommender' + apply plugin: 'java' + + repositories { + maven { url '${repo.root.absoluteFile.toURI()}' } + ${generator.mavenRepositoryBlock} + } + + configurations { + zinc + } + + dependencies { + nebulaRecommenderBom 'test.nebula.bom:testbom:2.0.0@pom' + zinc 'test.nebula:foo:1.0.0' + compile 'test.nebula:foo' + } + """.stripIndent() + + when: + def resultZinc = runTasksSuccessfully('dependencies', '--configuration', 'zinc') + + then: + resultZinc.standardOutput.contains '\\--- test.nebula:foo:1.0.0' + + when: + def resultCompileClasspath = runTasksSuccessfully('dependencies') + + then: + resultCompileClasspath.standardOutput.contains 'test.nebula:foo -> 2.0.0' + } + def 'dependencyInsight from recommendation via configuration'() { def repo = new MavenRepo() repo.root = new File(projectDir, 'build/bomrepo')