1

I have a Java maven project that depends on 50 jars that is not in Central Maven Repo or in my organization's Nexus repository. I don't want to do mvn install:install-file ... as it will work for me but it won't work for others unless they also run this command and install all the jars in their local repo.

I can put all my jars in project lib folder and check it in. But I need to hard code the path in the pom.xml for these jars.

Is there a way to handle this?

Damien-Amen
  • 7,232
  • 12
  • 46
  • 75
  • Don't really like the solution of adding it to version controle as they are binary files. Regarding the files in the lib folder do as this answer: http://stackoverflow.com/a/2230464/460557 . You really should send your libraries to your company repo (nexus or whatever) that way everyone on your company network would have access to it. – Jorge Campos Mar 21 '17 at 03:08
  • @JorgeCampos: So there are around 50 jars. Should I create a `` for each of these jars and do a `mvn deploy` ? Isn't it a bit tedious to create `` entry manually in `pom.xml` ? Is there a way to generate that easily? – Damien-Amen Mar 21 '17 at 03:22
  • 2
    @Damien-Amen Yes, deploy all the artifacts to your company Nexus/Artifactory, give them sensible groupId:artifactId:version and then put dependency entries into your pom. If you copy&paste the blocks, it is not much work. – J Fabian Meier Mar 21 '17 at 07:55
  • That definitely does not look like a great idea, however I suppose that this answer is the closest to get your behavior: http://stackoverflow.com/a/36602256/4121573 – Adonis Mar 21 '17 at 10:04
  • Even if it was 1000 it would be way better to have then in your company repository then in a local project. This is what maven is about. You only be concerned about your code. And do as @JFMeier said, create you pom and add then as dependency. No need to even copy e paste if you have a source control. Yes it is tedious BUT ONLY THE FIRST TIME YOU DO IT. You will avoid every person to be configuring their environment with all those jars every time they download the project. A simple mvn install would do it. – Jorge Campos Mar 21 '17 at 11:47
  • So Please let me know if these steps are correct 1. Add all the 3rd party jars to the `lib` folder in the project and check it in to `git` 2. Create a pom.xml with a dependency with all these jars (groupid, artifactid and version) 3. Do a `mvn deploy` ? But all these jars are going to be packed inside my project jar right? Let’s say my project name is `TestProject` and if I have all the 3rd party jars inside my `TestProject` `lib` folder. So when I do a `mvn deploy` it’s going to create a `TestProject.jar` which will contain all the jars inside? – Damien-Amen Mar 21 '17 at 13:42

0 Answers0