For Hibernate Developers, It's Time to Learn Gradle

DZone 's Guide to

For Hibernate Developers, It's Time to Learn Gradle

· Java Zone ·
Free Resource
The Hibernate team made it official when they recently switched the Hibernate 4 master branch on GitHub over to Gradle for its builds.  Now is as good a time as any to learn how the Gradle build system works in comparison to Hibernate's earlier build system, Maven 2.

If you're still wondering why the Hibernate developers decided to switch from Maven to Gradle, you can read these explanations and see what other developers had to say in this StackOverflow thread.

This is important news for anyone who's contributing to the open development of Hibernate.  Now, for those of you willing to try this Gradle thingy, it's always best to bookmark the project's documentation, which is mature and extensive.  This will be your go-to-guide for almost any question.  Since pre-4.0 versions of Hibernate use Maven for builds, most developers will want to know how certain things in Maven translate to Gradle.  For these developers, there is a three-part guide that helps Maven-users learn Gradle.

Intro to Gradle Video

JBoss developer Steve Ebersole also created a list of Gradle tasks that you will probably use the most:

  1. clean - Deletes the build directory.
  2. build - Assembles (jars) and tests this project.
  3. buildDependents - Assembles and tests this project and all projects that depend on it. So think of running this in hibernnate-entitymanager. Gradle would assemble and test hibernate-entitymanager as well as hibernate-envers because envers depends on entitymanager. See below.
  4. classes - compiles the main classes
  5. testClasses - compiles the test classes.
  6. test - Runs the tests for this project
  7. jar - Generates a jar archive with all the compiled classes.
  8. uploadArchives - think Maven deploy
  9. install - I have also enabled the MavenPlugin throughout the projects, which adds this task. install installs the project jar into the local maven repository cache (usually ~/.m2/repository), which is important to inter-operate between projects using Maven to build and those using Gradle to build (otherwise you'd have to push your artifacts to Nexus to “share”)

The newest version of Gradle is 0.9, which is currently in the release candidate stage.  Here's what's new in Gradle 0.9.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}