2

I have a need to convert the maven project to gradle project. All is going fine, but there is one problem that I faced, in the current project we are using dependency management throw parent pom of maven and in gradle as long as I researched there is no possibility to do so. I was thinking to convert somehow parent pom to maven bom and use in build.gradle because I know that gradle can use maven boms.

Do anyone have better ideas how to accoplish that ? Or may be someone also had this kind of problem, can suggest best ways to do it ?

Regards

BigGinDaHouse
  • 1,282
  • 9
  • 19

1 Answers1

1

You could use my gradle-maven-transform plugin to transform your pom.xmls into gradle scripts.

You can use the DependencyAggregator to find versions which are common across all projects and generate a root build.gradle containing the common versions.

Each project script can then reference a version variable from the root project instead of hard coding

You might choose to use nebula dependency recomnender plugin to manage common versions. The maven-transform plugin can generate scripts to support this style of declaration too

Whilst you are evaluating the gradle build you "apply" the generated gradle scripts in your gradle build. During this time both maven and gradle builds will work in parallel. Once your happy with the gradle build you copy paste the generated scripts into your build.gradle files and ditch maven for ever! Yay!

lance-java
  • 25,497
  • 4
  • 59
  • 101
  • That's all sounds good, I will check definetly, but in general the problem is that in our company dependency management was done via parent pom.xml file historically and now that's the only thing blocking me to migrate to gradle (which I like a lot). So there should be a way to still keep parent pom.xml file (at least for some time) and use the versions from that file. Is your project doing that as outcome ? – BigGinDaHouse Dec 07 '17 at 16:17
  • See the [maven bom provider](https://github.com/nebula-plugins/nebula-dependency-recommender-plugin/wiki/Maven-BOM-Provider) docs in the nebula dependency recommender. I think you could use your parent pom as a BOM. Assuming every version is in the parent pom, you could then use maven-transform-plugin and a custom freemarker template to generate gradle scripts from your project poms which omit the version numbers from the dependency declarations (as they will be injected by dependency recommender) – lance-java Dec 07 '17 at 16:25
  • that solved my issue, thanks a lot, marking your answer as correct – BigGinDaHouse Dec 08 '17 at 10:24
  • 1
    I might add the concept of `isManagedDependency(String groupId, String artifactId)` to the `maven-transform` plugin so that transformations can declare "managed" dependencies differently. This can be done manually currently... all the info is in the model... but I might make it easier out of the box – lance-java Dec 08 '17 at 12:04