1

It is nice to use maven to manage Java EE projects, and put all jar dependencies in pom.xml, so that you don't need to add these large jar files to your git version control repo.

this is wonderful especially when all the dependencies are in maven central repo.

if there is some jar lib which is not included by maven central repo, will you add these jar libs to git repo? or you will only upload these files to your local nexus server? (anyhow this is not nice if one day you are not with your local nexus server)

so what is your choice will you put jar file to git repo? or you will only define it in pom.xml? when such jar libs are not included by maven's central repo.

Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
hugemeow
  • 7,777
  • 13
  • 50
  • 63

3 Answers3

2

I think best approach to keep dependencies in local Nexus repository (and define it in pom.xml) instead Versions Control System

CAMOBAP
  • 5,523
  • 8
  • 58
  • 93
  • but sometimes you may be out, and cannot connect to that server, even worse, several years later, that local repo is no longer exist, then how can you build your code since mvn can only get the jar libs which are included by its central repo – hugemeow Sep 20 '12 at 14:21
  • 1
    @hugemeow equally well you might be someday without your repository. That is why you should be careful with keeping them, both. That doesn't change the fact that this is the most recommended solution and keeping them on the same git repo has big drawbacks. – eis Sep 20 '12 at 16:51
  • @eis sometime i cannot connect to my local repo, for example, i am not int the company, so is that better to put these jar files to git repo? – hugemeow Sep 20 '12 at 17:02
  • @hugemeow maven always stores the files in your local maven repo, anyway, so it'll work even when you are not in the network, as long as you download the dependencies when you are. see command `mvn dependency:go-offline` – eis Sep 20 '12 at 19:50
  • @eis yes, but i may use an online git repo, and use new pcs when i am travelling, so maybe it's better to store the jar libs to git since they are not in maven's official repo... – hugemeow Sep 20 '12 at 19:54
  • 1
    @hugemeow you're not making any sense :) `mvn dependency:go-offline` is meant to store any online maven dependency so they will work offline. If you use new pcs, they wouldn't have the git repo either, right? If they would have, then they'd have access to local maven repo, too. If you have some reasons why you insist on storing libs in git repo, you can do that, but it is definitely not recommended. You are free to ignore the recommendations however if you want to. – eis Sep 20 '12 at 19:58
  • i don't want to put jar libs to git repo, but i think sometimes i maybe force to do that:( – hugemeow Sep 20 '12 at 20:01
  • @eis jar files will be stored locally by default, if you don't push these jar lib to git repo(they are not in maven's officail repo), how can you get them if you cloned it from github? – hugemeow Sep 21 '12 at 05:02
  • @hugemeow ok, didn't realise that you use github or any public git hosting, for that matter. I made a [separate answer](http://stackoverflow.com/a/12525490/365237) based on that information. – eis Sep 21 '12 at 06:54
1

Apparently you're hosting your code in github and using it from locations that are not always in your company intranet. Basically, then, you have the following solutions available:

  1. Host a nexus (or similar) repository on your own public server, with authentication. This way it would be accessible from whereever you want it to. It can also be done on Amazon, for example.
  2. Use some of the free, open, hosted solutions. For example, Sonatype offers free hosting for open-source projects.
  3. As already suggested, you can host your maven repo also on github - don't store it on your code repo, create a separate project for it!
  4. Or.. just pay for hosting. There should be some supported solutions if you're willing to pay for it.

Any of these should work for you. From the way you described your situation, possibly option 3 is what you want. Any case, have them somewhere else than in your code repository.

EDIT: possibly I also overlooked the most self-evident solution for a closed-source development, so this would be an alternative 5. From a comment:

The smartest thing to do in this case would be to just put the repository behind your firewall and allow people from the outside to access it over your VPN. You could set up a publicly accessible service that requires all users to present some sort of credentials, but why open your repository to the outside world (and all the risks that entails) when you don't really need anyone from outside your organization to use it? Assuming of course, you have a VPN - but if you have remote employees, you should probably have a VPN so they can access your internal services securely.

This sounds reasonable, if your repo is not a public one.

Community
  • 1
  • 1
eis
  • 51,991
  • 13
  • 150
  • 199
  • option 3 is not that nice, since Snapshots and releases should be kept separate in Maven repositories, which means i should host all my libs on github, that may be too large, all i want is to host jar libs which are not in maven's central repo – hugemeow Sep 21 '12 at 16:25
0

If local server is not an option, then you can publish dependencies using git.

Here is example of url: https://github.com/plokhotnyuk/calculator/raw/master/repo

And content of repo should be copied from local maven repository: https://github.com/plokhotnyuk/calculator/tree/master/repo

Andriy Plokhotnyuk
  • 7,883
  • 2
  • 44
  • 68