Skip to content

Commit

Permalink
make sure we do not apply recommendations for provided versions by gr…
Browse files Browse the repository at this point in the history
…adle
  • Loading branch information
rpalcolea committed Oct 11, 2019
1 parent f909012 commit 4ca2021
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 4ca2021

Please sign in to comment.