<p>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?</p>

<p>What do other people do?</p>

[{'answer_id': 49198, 'author': 'Tony BenBrahim', 'author_id': 80075, 'author_profile': 'https://Stackoverflow.com/users/80075', 'pm_score': 7, 'selected': True, 'text': '<p>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</p>\n\n<p>Edit for 2017:\nThis answer did not age well:-). If you are still using something old like ant or make, the above still applies. If you use something more modern like maven or graddle (or Nuget on .net for example), with dependency management, you should be running a dependency management server, in addition to your version control server. As long as you have good backups of both, and your dependency management server does not delete old dependencies, you should be ok. For an example of a dependency management server, see for example <a href="https://www.sonatype.com/nexus-repository-oss" rel="noreferrer">Sonatype Nexus</a> or <a href="https://www.jfrog.com/open-source/" rel="noreferrer">JFrog Artifcatory</a>, among many others.</p>\n'}, {'answer_id': 49209, 'author': 'Stu Thompson', 'author_id': 2961, 'author_profile': 'https://Stackoverflow.com/users/2961', 'pm_score': 2, 'selected': False, 'text': "<p>I put everything except the JDK and IDE in source control.  </p>\n\n<p>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.</p>\n"}, {'answer_id': 49210, 'author': 'lomaxx', 'author_id': 493, 'author_profile': 'https://Stackoverflow.com/users/493', 'pm_score': 4, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 49215, 'author': 'Matt', 'author_id': 5024, 'author_profile': 'https://Stackoverflow.com/users/5024', 'pm_score': 1, 'selected': False, 'text': '<p>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.</p>\n\n<p>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.</p>\n'}, {'answer_id': 49225, 'author': 'minty', 'author_id': 4491, 'author_profile': 'https://Stackoverflow.com/users/4491', 'pm_score': 1, 'selected': False, 'text': '<p>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. </p>\n'}, {'answer_id': 49229, 'author': 'quick_dry', 'author_id': 3716, 'author_profile': 'https://Stackoverflow.com/users/3716', 'pm_score': 0, 'selected': False, 'text': "<p>store everything you'll need to build the project, so you can check it out and build without doing anything.</p>\n\n<p>(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)</p>\n"}, {'answer_id': 49291, 'author': 'Matt Sheppard', 'author_id': 797, 'author_profile': 'https://Stackoverflow.com/users/797', 'pm_score': 3, 'selected': False, 'text': "<p>I generally store them in the repository, but I do sympathise with your desire to keep the size down.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n"}, {'answer_id': 49335, 'author': 'reefnet_alex', 'author_id': 2745, 'author_profile': 'https://Stackoverflow.com/users/2745', 'pm_score': 5, 'selected': False, 'text': '<p>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 <a href="http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.advanced.vendorbr" rel="noreferrer">vendor branch</a> is worthwhile. </p>\n\n<p>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. </p>\n\n<p>Also, you can skip externals when updating your code base saving on the long slow load process should you need to.</p>\n\n<p>@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... :)</p>\n'}, {'answer_id': 64531, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>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.</p>\n'}, {'answer_id': 64590, 'author': 'Martin Gladdish', 'author_id': 7686, 'author_profile': 'https://Stackoverflow.com/users/7686', 'pm_score': 4, 'selected': False, 'text': '<p>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 <a href="http://maven.apache.org" rel="noreferrer" title="maven">maven</a> (or <a href="http://ant.apache.org/ivy/" rel="noreferrer" title="Ivy">Ivy</a> 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.</p>\n'}, {'answer_id': 64716, 'author': 'blahspam', 'author_id': 8290, 'author_profile': 'https://Stackoverflow.com/users/8290', 'pm_score': 2, 'selected': False, 'text': '<p>My preference is to store third party libraries in a dependency repository (<a href="http://www.jfrog.org/sites/artifactory/1.2/" rel="nofollow noreferrer">Artifactory</a> with <a href="http://maven.apache.org/" rel="nofollow noreferrer">Maven</a> for example) rather than keeping them in Subversion. </p>\n\n<p>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.</p>\n'}, {'answer_id': 67463, 'author': 'Vladimir', 'author_id': 9641, 'author_profile': 'https://Stackoverflow.com/users/9641', 'pm_score': 3, 'selected': False, 'text': '<p>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:</p>\n\n<ol>\n<li>why storing files that don\'t change into a system specifically designed to manage files that change?</li>\n<li>it dramatically fasten the check-outs</li>\n<li>each time I see "something.jar" stored under source control I ask "and which version is it?"</li>\n</ol>\n'}, {'answer_id': 363141, 'author': 'Eran Kampf', 'author_id': 1228206, 'author_profile': 'https://Stackoverflow.com/users/1228206', 'pm_score': 0, 'selected': False, 'text': "<p>You have to store everything you need in order to build the project.\nFurthermore different versions of your code may have different dependencies on 3rd parties.\nYou'll want to branch your code into maintenance version together with its 3rd party dependencies...</p>\n"}, {'answer_id': 363175, 'author': 'RSlaughter', 'author_id': 40848, 'author_profile': 'https://Stackoverflow.com/users/40848', 'pm_score': 1, 'selected': False, 'text': "<p>Personally I have a dependancies folder as part of my projects and store referenced libraries in there.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n\n<p>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.</p>\n"}, {'answer_id': 414376, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': False, 'text': '<p>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. </p>\n'}, {'answer_id': 2994067, 'author': 'Ken Bloom', 'author_id': 197788, 'author_profile': 'https://Stackoverflow.com/users/197788', 'pm_score': 1, 'selected': False, 'text': "<p>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.</p>\n"}, {'answer_id': 6453466, 'author': 'jpierson', 'author_id': 83658, 'author_profile': 'https://Stackoverflow.com/users/83658', 'pm_score': 0, 'selected': False, 'text': "<p>Personally what I have done and have so far liked the results is store libraries in a separate repository and then link to each library that I need in my other repositories through the use of the Subversion svn:externals feature. This works nice because I can keep versioned copies of most of our libraries (mainly managed .NET assemblies) in source control without them bulking up the size of our main source code repository at all. Having the assemblies stored in the repository in this fashion makes it so that the build server doesn't have to have them installed to make a build. I will say that getting a build to succeed in absence of Visual Studio being installed was quite a chore but now that we got it working we are happy with it.</p>\n\n<p>Note that we don't currently use many commercial third-party control suites or that sort of thing much so we haven't run into licensing issues where it may be required to actually install an SDK on the build server but I can see where that could easily become a problem. Unfortunately I don't have a solution for that and will plan on addressing it when I first run into it.</p>\n"}]
['https://Stackoverflow.com/questions/49196', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/342/']