@lucarossi93 you could do a build scan, it might help track some issues down:
https://scans.gradle.com/
Give the Gradle process more memory.
What type of machine are you running the build on? Does it have enough memory, CPU, are you running other things on that system that could be slowing the process down. How long does it take to build locally vs on your build machine?
Also if you have any Groovy files that are 4000+ lines of code, refactor and break them up. The compiler slows down exponentially once you go over 3 or 4 thousand lines of code.
Out of curiosity how big is your code base? I have one multi-project gradle build that totals ~850k LOC with some files that are 4000 lines + and that takes about 12 min to build and run locally, and about 15 min on the build server. Although I'm also on Grails 5.3 at this point, however, I don't think that helps a tremendous amount in compilation time. Although it might have some impact as it does have a newer version of Gradle. One word of caution you do have to upgrade Grails and Gradle in lock step for major versions, and Grails is usually made to work with one major version.