tags:

views:

685

answers:

5

For my previous employer I've worked with Hibernate, and now that I'm in a small startup I would like to use it again. However, downloading both the Hibernate core and the Hibernate annotations distributions is rather painful, as it requires putting a lot of JAR files together. Because the JARs are split up into categories such as "required" and "optional" I would assume that every developer ends up with a different contents of his lib folder.

What is the common way to handle this problem? Basically I want to have a formal way to get all the JARs for Hibernate, so that (in theory) I would end up with exactly the same stuff if I would need again for another project next month.

Edit: I know roughly what Maven does, but I was wondering if there was another way to manage this sort of thing.

+1  A: 

I use Maven 2 and have it manage my dependencies for me.

Aaron Digulla
+3  A: 

As Aaron has already mentioned, Maven is an option.

If you want something a bit more flexible you could use Apache Ant with Ivy.

Ivy is a dependency resolution tool which works in a similar way to Maven, you just define what libraries your project needs and it will go off and download all the dependencies for you.

Phill Sacre
A: 

I assume you use the Hibernate APIs explicitly? Is it an option to use a standard API, let's say JPA, and let a J2EE container manage the implementation for you?

Otherwise, go with Maven or Ivy, depending on your current build system of choice.

Magnus
+1  A: 

One word of caution when considering using Maven or Ivy for managing dependencies is that the quality of the repository directly affects your build experience. If the repo is unavailable or the meta-data for the artifacts (pom.xml or ivy.xml) is incorrect you might not be able to build. Building your own local repository takes some work but is probably worth the effort. Ivy, for example, has an ANT task that will import artifacts from a Maven repository and publish them to you own Ivy repository. Once you have a local copy of the Maven repo, you can adjust the meta-data to fit what ever scheme you see fit to use. Sometimes the latest and greatest release is not in the public repository which can sometimes be an issue.

kurron
+2  A: 

Maybe this is not much of an answer, but I really don't see any problem with Hibernate dependencies. Along with hibernate3.jar, you need to have:

  1. 6 required jars, out of which commons-collections, dom4j and slf4j are more often used in other open-source projects
  2. 1 of either javassist or CGLIB jars
  3. depending on cache and connection pooling, up to 2 jar files, which are pretty much Hibernate specific

So, at the very worst, you will have a maximum of 10 jars, Hibernate's own jar included. And out of those, only commons-collections, dom4j and slf4j will probably be used by some other library in your project. That is hardly a zillion, it can be managed easily, and surely does not warrant using an "elephant" like Maven.

javashlook