Trying Gradle
I was very interested to try out Gradle and see how it compares to Maven. I knew that both tools are very similar but Gradle is more flexible and has a more compact syntax. In this blog post I will discuss in depth my first experience with Gradle.
My first experience with Gradle started out pretty positive. The config file was very compact and easy to manage. I still don't fully understand all the different ways to add a dependency (implementation vs compile, etc). I know maven has the same thing with scope, but it seems to be less advanced and most people don't really use it. I assume that it is also not that important when using Gradle but there are some that are important such as the annotation processor.
Regarding that I was also confused that the order in which you list your dependencies has an impact on the actual build, and this is mainly related to the annotation processor. I got some compile errors because I didn't had Lombok as my first dependency. When you understand this, it does make sense. Lombok needs to generate all the code first because the rest of your application can use it, but still. This means you need to know the dependencies between your dependencies and use those to specify the order of the them. Maven seems to handle this differently and dependencies are just dependencies. It is the actual build config part that has to take care of all of this.
I still like the more compact syntax of Gradle, but I do wonder why you would extract version numbers out of it. This can be important when you have a tool that supplies multiple dependencies (such as junit with the parameters). You want to keep all these dependencies in-tune with each other and make sure that you use the same version of them. In Maven you do this by extracting the version into a variable and use that variable instead. I assume (actually hope) that something like that is also possible in Gradle.
After installing the Gradle plugin for VSCode, I was shocked to see how many different targets there are. This makes it difficult to figure out what is the difference between all of them and which to execute when. In the end I only every used 3 of them and the application seemed to work fine. I guess this is where the flexibility of Gradle gets involved, you can't have your cake and eat it too. It isn't really that big of a deal, but it just creates a hurdle to really get to fully understand Gradle, which may not be required. If you know enough about how the tool works and how to get started that can be enough to start using it and the rest will follow.
Finally I did have issues with the test runs. For some reason Gradle doesn't really log much when your tests pass. I am used to the Maven out put that logs how many tests it executed, how many failed, passed, skipped and caused an error. Gradle being to quiet is annoying because I wasn't sure it was actually executing any test. I had to add something in the configuration to make it log something to give me that ease of mind.
In the end I tried Gradle with Micronaut in VSCode, which seemed to be a mistake. Although Gradle and Micronaut worked from the command line, getting it to work properly in VSCode just didn't happen. I turned back to my familiar maven which seems to have better support and works as expected.
As a conclusion I can say that while Gradle has a nicer more compact syntax, I never felt that Maven was a problem to use. Having a tool that guides you more and restricts you in your freedom and even forces you to do something in a particular way is not a bad thing. It creates familiarity and consistency across projects. For the time being I will just keep using Maven.