views:

1458

answers:

16

Should libraries that the application relies on be stored in source control? One part of me says it should and another part say's no. It feels wrong to add a 20mb library that dwarfs the entire app just because you rely on a couple of functions from it (albeit rather heavily). Should you just store the jar/dll or maybe even the distributed zip/tar of the project?

What do other people do?

+26  A: 

store everything you will need to build the project 10 years from now.I store the entire zip distribution of any library, just in case

Tony BenBrahim
So does that include say Eclipse or Visual Studio?
jpierson
+1  A: 

I put everything except the JDK and IDE in source control.

Tony's philosophy is sound. Don't forget database creation scripts and data structure update scripts. Before wikis came out, I used to even store our documentation in source control.

Stu Thompson
+5  A: 

We store the libraries in source control because we want to be able to build a project by simply checking out the source code and running the build script. If you aren't able to get latest and build in one step then you're only going to run into problems later on.

lomaxx
+1  A: 

Store third party libraries in source control so they are available if you check your code out to a new development environment. Any "includes" or build commands that you may have in build scripts should also reference these "local" copies.

As well as ensuring that third party code or libraries that you depend on are always available to you, it should also mean that code is (almost) ready to build on a fresh PC or user account when new developers join the team.

Matt
A: 

Store the libraries! The repository should be a snapshot of what is required to build a project at any moment in time. As the project requires different version of external libraries you will want to update / check in the newer versions of these libraries. That way you will be able to get all the right version to go with an old snapshot if you have to patch an older release etc.

minty
A: 

store everything you'll need to build the project, so you can check it out and build without doing anything.

(and, as someone who has experienced the pain - please keep a copy of everything needed to get the controls installed and working on a dev platform. I once got a project that could build - but without an installation file and reg keys, you couldn't make any alterations to the third-party control layout. That was a fun rewrite)

Steven Adams
+5  A: 

I generally store them in the repository, but I do sympathise with your desire to keep the size down.

If you don't store them in the repository, the absolutely do need to be archived and versioned somehow, and your build system needs to know how to get them. Lots of people in Java world seem to use Maven for fetching dependencies automatically, but I've not used I, so I can't really recommend for or against it.

One good option might be to keep a separate repository of third party systems. If you're on Subversion, you could then use subversion's externals support to automatically check out the libraries form the other repository. Otherwise, I'd suggest keeping an internal Anonymous FTP (or similar) server which your build system can automatically fetch requirements from. Obviously you'll want to make sure you keep all the old versions of libraries, and have everything there backed up along with your repository.

Matt Sheppard
Liking the separate repository idea. Solves the issue where remote users have access ONLY to source control (i.e. they cannot get to the anonumous FTP or wherever else you've put the 3rd party stuff). I acknowledge that it's kind of broken to have giant unchanging binaries in source control, but this at least isolates them to a single repo.
overthink
+10  A: 

As well as having third party libraries in your repository, it's worth doing it in such a way that makes it easy to track and merge in future updates to the library easily (for example, security fixes etc.). If you are using Subversion using a proper vendor branch is worthwhile.

If you know that it'd be a cold day in hell before you'll be modifying your third party's code then (as @Matt Sheppard said) an external makes sense and gives you the added benefit that it becomes very easy to switch up to the latest version of the library should security updates or a must-have new feature make that desirable.

Also, you can skip externals when updating your code base saving on the long slow load process should you need to.

@Stu Thompson mentions storing documentation etc. in source control. In bigger projects I've stored our entire "clients" folder in source control including invoices / bills/ meeting minutes / technical specifications etc. The whole shooting match. Although, ahem, do remember to store these in a SEPARATE repository from the one you'll be making available to: other developers; the client; your "browser source view"...cough... :)

reefnet_alex
What about when the third party libraries need to be licensed on each developers workstation via an installer?
jpierson
+1, but would what about distributed SC like git or hg? PS: best SO avatar icon.... ever
slf
A: 

At a previous employer we stored everything necessary to build the application(s) in source control. Spinning up a new build machine was a matter of syncing with the source control and installing the necessary software.

To me there seems to be some gray area between "necessary software" and "everything necessary to build the application". Isn't a compiler necessary to build the application? Also many SDKs and third party libraries require installation on the developers workstation. Where do we draw the line and how are third party .NET libraries stored in source control when they are typically expected to be in the GAC?
jpierson
+5  A: 

Don't store the libraries; they're not strictly speaking part of your project and uselessy take up room in your revision control system. Do, however, use maven (or Ivy for ant builds) to keep track of what versions of external libraries your project uses. You should run a mirror of the repo within your organisation (that is backed up) to ensure you always have the dependencies under your control. This ought to give you the best of both worlds; external jars outside your project, but still reliably available and centrally accessible.

Martin Gladdish
+1  A: 

My preference is to store third party libraries in a dependency repository (Artifactory with Maven for example) rather than keeping them in Subversion.

Since third party libraries aren't managed or versioned like source code, it doesn't make a lot of sense to intermingle them. Remote developers also appreciate not having to download large libraries over a slow WPN link when they can get them more easily from any number of public repositories.

blahspam
+1  A: 

What I have is an intranet Maven-like repository where all 3rd party libraries are stored (not only the libraries, but their respective source distribution with documentation, Javadoc and everything). The reason are the following:

  1. why storing files that don't change into a system specifically designed to manage files that change?
  2. it dramatically fasten the check-outs
  3. each time I see "something.jar" stored under source control I ask "and which version is it?"
Vladimir
A: 

You have to store everything you need in order to build the project. Furthermore different versions of your code may have different dependencies on 3rd parties. You'll want to branch your code into maintenance version together with its 3rd party dependencies...

Eran Kampf
A: 

Personally I have a dependancies folder as part of my projects and store referenced libraries in there.

I find this makes life easier as I work on a number of different projects, often with inter-depending parts that need the same version of a library meaning it's not always feasible to update to the latest version of a given library.

Having all dependancies used at compile time for each project means that a few years down the line when things have moved on, I can still build any part of a project without worrying about breaking other parts. Upgrading to a new version of a library is simply a case of replacing the file and rebuilding related components, not too difficult to manage if need be.

Having said that, I find most of the libraries I reference are relatively small weighing in at around a few hundred kb, rarely bigger, which makes it less of an issue for me to just stick them in source control.

RSlaughter
+1  A: 

never store your 3rd party binaries in source control. Source control systems are platforms that support concurrent file sharing, parallel work, merging efforts, and change history. Source control is not an FTP site for binaries. 3rd party assemblies are NOT source code; they change maybe twice per SDLC. The desire to be able to wipe your workspace clean, pull everything down from source control and build does not mean 3rd party assemblies need to be stuck in source control. You can use build scripts to control pulling 3rd party assemblies from a distribution server. If you are worried about controlling what branch/version of your application uses a particular 3rd party component, then you can control that through build scripts as well. People have mentioned Maven for Java, and you can do something similar with MSBuild for .Net.

A: 

Use git subprojects, and either reference from the 3rd party library's main git repository, or (if it doesn't have one) create a new git repository for each required library. There's nothing reason why you're limited to just one git repository, and I don't recommend you use somebody else's project as merely a directory in your own.

Ken Bloom