views:

310

answers:

8

Hello,

When you start to use a third party library in Java, you add their jars to your project. Do you also add the jars to the repository or do you just keep a local installation. And if the latter, how do you sync between team members to be able to work?

Thanks.

+8  A: 

No, if you use Maven. Put them into Maven repository (if they are not there yet, most open source libraries are in public Maven repositories already).

Yes, if you use Ant.

Peter Štibraný
Even if you use maven you cannot be guaranteed that the jars exist on the internet in exactly the same version as you used to test it... two years ago. Use a Nexus proxy which loads once and back that up to ensure you have the right, tested, jar version at all times.
extraneon
If you use Ant, consider Ivy.
A: 

Lately I've been keeping JARs out of SVN. I have a separate repository that I use to pull them into projects, manage dependencies, and keep track of different versions.

This is what Maven is born for. I've got to learn how to use it well, but until then I'm keeping my own JAR repository.

duffymo
+1  A: 

I would recommend versioning everything you need to build a project. Unless your using a build tool like maven.

zodeus
+4  A: 

If you're using ANT and you want maven style dependency management without maven, take a look at Ivy. It can download from maven repositories and can even read maven pom files.

sblundy
+9  A: 

Yes. You should add to the repository whatever is required for a developer on a clean system (aside from having the JDK and ant installed) to check out and build the project.

Eric Asberry
+1 Absolutely! It's a pain if build doesn't work straight out of repository.
Peter Štibraný
People whose projects don't compile on a clean checkout should be shot
matt b
+3  A: 

Yes, third-party libraries should be version controlled since you will want everyone to compile against the same version of that library. This way when updates to that third-party library happen you will simply have to change it in one place and everyone will update to the new version. Otherwise you could easily end up with the famous: "It compiles on my machine!"-syndrome.

Ben S
A: 

Short Answer

No

Longer answer

In the interim, use a folder on your network separate from the repo.

A Long Term Solution

Use maven. It was built for handling your build, configuration and external jar dependencies.

Go here for documentation though. (The official maven documentation is known to be pretty spotty).

Trampas Kirk
That implies there's a common network other than the Internet for the team. Which is not the case.
J. Pablo Fernández
+2  A: 

Assuming you do not use Maven, then you should definitely check in versions of 3rd party jars. You (or more importantly, the maintenance developer coming along after you) should be able to pull a version of your application from the repository and have all the correct versions of all the 3rd party jars required at compile- and runtime.

You also should maintain the versioning history of the 3rd party jars, again to help the maintenance developer out. Checking them in to the repository is the easiest and most effective way to do this.

Alan Nickell