Sample Gradle Build
pgier Jul 19, 2010 10:58 AMI created a sample gradle build and it's available in my git tree (http://github.com/pgier/jboss-as/tree/gradle).
If you want to try it out, just pull from my tree into a branch called "gradle"
git remote add git remote add pgier git://github.com/pgier/jboss-as.git git branch pgier/gradle git checkout pgier/gradle git pull pgier gradle
Then download and install gradle 0.9 if you don't already have it (http://www.gradle.org/). And run the build
gradle clean build dist
I'm mainly interested in Gradle because it could solve our issues of
- a single place to define the version for a multi-module project
- deploying poms with resolved snapshots
- more flexibility for the distribution build (right now we're using Ant via the antrun plugin)
- easier management of dependencies across modules
The build script is not quite complete, but the basic stuff is there, and here are some observations.
Advantages of Gradle
- The build scripts are smaller, a big part of this is the fact that gradle uses groovy instead of xml, but it is also quite a bit easier to reuse bits of code throughout the build
- The build.gradle script in the root directory can handle both the module agreggation and the distribution build in the "build" directory, instead of having two poms for this in Maven
- Gradle has some interesting optimizations, for example it won't re-run the unit tests if the code has not changed
- I haven't set the pom generation up yet, but Gradle includes some features to generate POMs. This means that we could generate poms that include resolved snapshot dependencies. We also would not need to deploy any parent/aggregator pom to the repository
Advantages of Maven
- We have a lot of Maven knowledge already, and Gradle has a significant learning curve (this might be easier for people familiar with groovy)
- This would be especially important for our community members trying to checkout and build
- Maven forces consistency among projects, and it's easy to see how a Gradle build could become complex to the point of being difficult to maintain.
- I haven't looked into the reporting features of Gradle yet, but it might not be as easy to use as Maven
Other Notes
The speed of the builds seem to be similar. For me this was about 15s for a clean build and 8s for an incremental build.
Overall Gradle is very interesting because there are lots of possiblities that open up when your build scripts are actual code instead of just a set of plugins, but it's easy to see that the complexity of a gradle build could get out of control.
I prefer Maven's logging which is more verbose than gradle. Maven prints out the log level and prints summary information at the end of the build. Gradle's logging seems to be based on the steps of the build and not so much grouped by module.