Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jar Dependencies in GitHub

I'm setting up a new Java project on GitHub, and I'll have some Apache Commons libraries as dependencies.

What are the best practices to establish that my project needs those jar files? Should I upload the dependencies to my GitHub repository (ugly)? Or use a Maven-like tool for that?

Or is there a way to link a file in another git repository? Apache provides git repositories for they libraries. They are read-only, but I'm o.k. with that, since I just want to use the jars. The bad thing is that they contain all the sources, and I just care about the compiled jar. It seems we can't git submodule just a file.

like image 488
bruno Avatar asked Jun 05 '14 19:06

bruno


1 Answers

The two approaches are:

  • declarative and component-based, where you declare (describe) what components (jars, exe, other binaries) you need for your project to (compile, execute, deploy, etc.), and you use a third-party tool (like Maven/Nexus) to bring those components on demand.
    So they aren't versioned in your repo. They are declared/described (like in a pom.xml, if you were to use Nexus)
    See also "Difference between Git and Nexus?".

  • inclusive and system-based, where you complete your project with other project sources/binaries, in order to get in your repo everything you need right after the clone step (no need to call a third-party tool or to do anything: every other part of your system in there).
    With Git, especially if those "other parts" are in a git repo (like the apache libs one), then you would declare those sub-repos as submodules of your main repo.
    That way, all you keep in your main repo is a special entry (gitlink, mode 160000) referencing a specific SHA1 of another repo (but you can make that submodule follow a branch too, a bit like svn external).
    And with sparse checkouts in submodules (as in this example), you even can update those modules for them to checkout only the part of the repo you want (like just the jars, not the sources).

Note that you aren't supposed to store any delivery that you would produce (like jars of your own) in your GitHub repo.

You can associate those deliveries to GitHub releases though.

like image 145
VonC Avatar answered Oct 21 '22 09:10

VonC