r/javahelp • u/HorseOnOldTimeRoad • Dec 22 '19
Maven and Gradle
I've been coding java now for about a good year, where i've always used maven. A few days ago I tried to use gradle, only for dependency management in a very small project.
When looking a different githubs I sometimes see projects that use both maven and gradle, for me they are both just similar build tools. One in XML and the other in groovy(?). What is the value of using both together?
4
u/Talulabelle Dec 22 '19
Just to throw out a wild guess, but I'll bet the maintainers couldn't agree.
2
u/__helix__ Dec 22 '19
Maven fixed many defects with Ant, Gradle attempts to fill in some of the gaps in Maven. We've got a 50/50 split in most of our build processes. Longer term, Gradle seems to be where 'newer' stuff is going. Just like Java... there is a hell of a lot of Maven out there, and it just works.
If you are messing with cutting edge libraries.. there is a better chance of Gradle having it. Also a better chance of getting cut. :) . Pick one and learn it reasonably well. Pick the other when you find out the team is shifting to a new build process.
2
u/aram535 Dec 22 '19
Different approaches to build and dependency management. One of procedural and one is a functional way of building your tool. One is a monolith application, the other is a plugin based distributed set of functions that interact.
Just like the Network-as-code, Infrastructure-as-code, etc... I think a functional design to build tools makes sense. For someone looking at the project they can easily tell within the first minute what is going on quickly. Take any large project THAT YOU'RE NOT FAMILIAR with, that produces multiple artifacts, builds, tests, and generate documentation on distribution and see if you can make it do one more thing and how long it'll take you. Now do the same with Gradle and you'll see the speed in understanding the requirements.
This is the personal bit -- it's completely subjective and it works for me. I became a fan of Gradle in 2007 soon after they released. To me, Gradle is faster, easier and has better dependency management, easier configuration options. With the additive that you can do modular design to your build tool and move it into a central location so that all of your builds use a single starting point sold me. I have not looked back once.
1
u/cmhdave73 Dec 22 '19
I'm not sure I understand how this would even work. I suppose you could have a pom.xml and build.gradle in different parts of the project but you would have to run maven from gradle or gradle from maven. OR maybe even run them separately during different phases of the build (which again would seem weird).
These are two tools that generally do the same thing and it's a matter of preference on which one a project uses.
0
Dec 22 '19
[deleted]
2
u/HorseOnOldTimeRoad Dec 22 '19
Alright, thanks for the explanation, helps alot in understand this subject!
4
u/bawng Dec 22 '19
Gradle has a habit of breaking things and plugin authors sometimes struggle to keep up with the changes. The Maven ecosystem offers more stability in that regard.
This is symptomatic for the different philosophies of the two tools. Maven aims to be opinionated while Gradle aims to be flexible. I.e. Maven has a more standardized and rigid structure that seldom breaks but offers less in terms of customisation, where Gradle has very little structure, which may cause things to break at times since there's no contract to maintain. On the other hand you can more easily do custom stuff with Gradle.
All in all it's a trade-off. I usually use Gradle for personal stuff and Maven for work-stuff or stuff that will likely be used by others. Sometimes I use both.
2
u/wildjokers Dec 22 '19
Generally they are mutually exclusive and it would be odd to use both unless a project was in transition from one to the other.
Can you provide a link to a project using both?