Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Allow easy pass-through of other recommendations. #19

Open
noel-yap opened this issue Jul 15, 2016 · 5 comments
Open

Allow easy pass-through of other recommendations. #19

noel-yap opened this issue Jul 15, 2016 · 5 comments

Comments

@noel-yap
Copy link
Contributor

We would like to be able easily to pass through other recommendations BOM, something like:

dependencies {
  recommendation 'netflix.grpc:netflix-grpc-recommendations:latest.release@pom'
}

where netflix.grpc:netflix-grpc-recommendations:latest.release@pom is the other recommendations BOM to be passed through. This can be done with some logic in the build.gradle file. It would be more readable and less complex to the maintainer of that file if that logic were abstracted away and hidden within the recommendations plugin itself.

@noel-yap
Copy link
Contributor Author

noel-yap commented Jul 15, 2016

It looks like MavenBomRecommendationProvider exists. Let me try that.

@noel-yap noel-yap reopened this Jul 26, 2016
@noel-yap
Copy link
Contributor Author

MavenBomRecommendationProvider has the BOM include the pom file itself, not what it's recommending.

@DanielThomas
Copy link
Contributor

netflix.nebula.dependency.recommender.publisher.MavenBomXmlGenerator is the guy responsible for generating the dependencyManagement XML. That's where we'd need to pull any POMs and merge any dependencies or dependencyManagement sections.

@noel-yap
Copy link
Contributor Author

noel-yap commented Jul 26, 2016

For others who may want to be doing something similar and possibly as a foundation for implementing this functionality directly in the plugin, the following is what I did:

configurations {
  passThroughRecommendationsOf
}

dependencies {
  passThroughRecommendationsOf 'netflix.grpc:netflix-grpc-recommendations:latest.release@pom'

  project.configurations.passThroughRecommendationsOf.resolvedConfiguration.getFiles(org.gradle.api.specs.Specs.SATISFIES_ALL).each {
    final pomXml = new XmlSlurper().parseText(it.text)

    pomXml.dependencyManagement.dependencies.dependency.each {
      recommendation "${it.groupId.text()}:${it.artifactId.text()}:${it.version.text()}"
    }
  }
}

@gregallen
Copy link

slight simplification:

configurations.passThroughRecommendationsOf.resolvedConfiguration.resolvedArtifacts.each {
    logger.info "Importing bom: $it.id"
    new XmlSlurper().parse(it.file).dependencyManagement.dependencies.dependency.each {
        compile "${it.groupId.text()}:${it.artifactId.text()}:${it.version.text()}"
    }
}

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants