Help

Hibernate 4 (master branch on GitHub) has been switched to use Gradle for its builds. Mainly I just liked the alliteration of Git and Gradle... :)

The Gradle User Guide is a good reference obviously. Most of what we use gets introduced by the JavaPlugin

gradle -t is a handy thing to know. It will tell you all the main tasks available in a project. Note however that it does not reach into subprojects. For example, assuming you are at the root of the Hibernate project checkout if you run gradle -t you would see nothing about tasks related to compiling, which is obviously essential :) In Gradle when you run a task against a project, that task request is passed along to any subprojects also. So I'd suggest cd'ing around a bit and doing gradle -t to get a feel for the tasks available. An alternative is to run gradle -t --all which shows all tasks for that project; just beware that that can get extremely verbose.

That being said, the here is a list of the most common tasks you will use:

  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)

A note about build and buildDependents. Gradle, unlike Maven, acts better in the face of inter-module dependences. In Gradle, if I cd into hibernate-entitymanager and perform a build, Gradle will automatically try to build hibernate-core for me if it needs to. For build it stops there. If you also want it to recompile things that depend on your changes, you would instead use buildDependents. So from hibernate-entitymanager again, if I this time run buildDependents it will first build hibernate-core, then hibernate-entitymanager and then hibernate-envers.

14 comments:
 
14. Oct 2010, 23:08 CET | Link
Adrian Mitev

What's the reason for switching from maven?

ReplyQuote
 
15. Oct 2010, 08:38 CET | Link
Jan Groth

I perfectly understand and accept that there are advantages from Gradle of Maven.

Just want to mention that using a different (aka unfamiliar for most of us) build management raises the barrier for contributing.

Hope you guys sorted that out...

cheers,

Jan

 
15. Oct 2010, 09:53 CET | Link
julien

I'm sad to see an important project like Hibernate switching from Maven to a confidential build system (especially because Hibernate is not a groovy project).

Gradle, unlike Maven, acts better in the face of inter-module dependences.
cd hibernate-entitymanager && gradle build <=> mvn -pl hibernate-entitymanager -am
cd hibernate-entitymanager && gradle buildDependents <=> mvn -pl hibernate-entitymanager -amd

What about integration with Eclipse (resource filtering, workspace resolution, ...)? Are you using Sonar?

I don't think build.gradle is more understandable than pom.xml. But I'm biased as I know Maven very well but not Groovy.

I really hope you will revert to Maven once the Gradle fashion will be over.

 
15. Oct 2010, 14:07 CET | Link

Not a real surprise given earlier posts, but as julien stated, I hope this is not a fashion-driven choice. As long as it doesn't interfere with my Hibernate usage, it's not really a big deal for me.

 
15. Oct 2010, 15:47 CET | Link
Pascal

Like others, I consider this as an important regression (yeah, back to Ant non standard tasks...). And I don't see how Gradle acts better in the face of inter-module dependences given that everything shown in this post is also available in Maven. This is very sad, especially given the recent release of Maven 3, it's IDE support, tools like Maven Shell.

 
16. Oct 2010, 02:53 CET | Link
julien wrote on Oct 15, 2010 03:53:
I'm sad to see an important project like Hibernate switching from Maven to a confidential build system (especially because Hibernate is not a groovy project).

What is confidential supposed to mean exactly?

Gradle, unlike Maven, acts better in the face of inter-module dependences.
cd hibernate-entitymanager && gradle build <=> mvn -pl hibernate-entitymanager -am
cd hibernate-entitymanager && gradle buildDependents <=> mvn -pl hibernate-entitymanager -amd

Well we'll just agree to disagree. IMO you just made my point that Gradle is simpler here.

What about integration with Eclipse (resource filtering, workspace resolution, ...)? Are you using Sonar?

gradle eclipse

Why do you care if Hibernate uses Sonar? You don't I assume. You care about your project using Sonar, which Hibernate using Gradle to build has no effect on.

I don't think build.gradle is more understandable than pom.xml. But I'm biased as I know Maven very well but not Groovy.

Yeah but you fail to notice the overall simpler structure of the 2 builds, like the fact that Maven forces use to split the main testsuite out of the module its testing because of its stupid enforcement that all projects produce only a single artifact. Or the insane difficulty in making release bundles. Or doing releases in general.

 
16. Oct 2010, 02:54 CET | Link
Adrian Mitev wrote on Oct 14, 2010 17:08:
What's the reason for switching from maven?

I've already outlined all the reasons I decided on switch to use Gradle in previous blog entries here as well as http://community.jboss.org/wiki/Gradlewhy

 
16. Oct 2010, 02:55 CET | Link
Jan Groth wrote on Oct 15, 2010 02:38:
I perfectly understand and accept that there are advantages from Gradle of Maven. Just want to mention that using a different (aka unfamiliar for most of us) build management raises the barrier for contributing. Hope you guys sorted that out... cheers, Jan

Well we shall see I guess

 
16. Oct 2010, 03:00 CET | Link
Pascal wrote on Oct 15, 2010 09:47:
Like others, I consider this as an important regression (yeah, back to Ant non standard tasks...). And I don't see how Gradle acts better in the face of inter-module dependences given that everything shown in this post is also available in Maven. This is very sad, especially given the recent release of Maven 3, it's IDE support, tools like Maven Shell.

Hibernate was the first JBoss project to switch to Maven, and I heard all these same exact arguments back then when I made that decision. I personally find it completely hilarious, especially how may of those same people now are the ones arguing Hibernate should not move away from Maven.

 
16. Oct 2010, 03:02 CET | Link
lievendoclo wrote on Oct 15, 2010 08:07:
Not a real surprise given earlier posts, but as julien stated, I hope this is not a fashion-driven choice. As long as it doesn't interfere with my Hibernate usage, it's not really a big deal for me.

Um, as posted in my earlier comment go back and look at my frustrations dealing with square pegs maven forces on us. Those blogs go back years. Hardly a fashion choice thank you very much.

 
17. Oct 2010, 20:06 CET | Link
Ray

Ignore the nay sayer. You need to do what keeps you happy working with this project. It's a bold move - I for one welcome it.

Convention over Configuration, yes, but do not patronize the user. This will drive people away in the end.

 
17. Oct 2010, 20:38 CET | Link
lievendoclo
Um, as posted in my earlier comment go back and look at my frustrations dealing with square pegs maven forces on us. Those blogs go back years. Hardly a fashion choice thank you very much.

I'm not saying it is. Frankly, I couldn't care less if you used Maven, Gradle, Buildr or any other build tool. As long as Hibernate releases keep showing up in Maven repositories without requiring changes, I'm a happy camper. Just being curious: have you ever contacted Jason Van Zyl or anyone else from Sonatype in regards to your problems with Maven?

 
17. Oct 2010, 23:33 CET | Link
lievendoclo wrote on Oct 17, 2010 14:38:
Um, as posted in my earlier comment go back and look at my frustrations dealing with square pegs maven forces on us. Those blogs go back years. Hardly a fashion choice thank you very much. I'm not saying it is. Frankly, I couldn't care less if you used Maven, Gradle, Buildr or any other build tool. As long as Hibernate releases keep showing up in Maven repositories without requiring changes, I'm a happy camper. Just being curious: have you ever contacted Jason Van Zyl or anyone else from Sonatype in regards to your problems with Maven?

I've spoken with Jason and other Maven developers numerous times, yes.

 
31. Jul 2014, 13:14 CET | Link
jack

Bloony Wheel, is a scientific cycle game with one wheel and balloon on boynton beach teeth whitening other head. based on physics unicycle game. You target here is to control the game by balancing the balloon and the wheel. Play and enjoy Bloony wheel game

Post Comment