Sait
Sait

Reputation: 19805

Add jar to maven project & git integration

I have a maven-java project and I use git at the same time. Now I need to use some libraries which does not have any maven support. I have the .jar files of the libraries.

How will I add them to my maven project? and.. Will the other people who pull my code from my git repo be able to run my code without having the .jars?

Upvotes: 1

Views: 596

Answers (2)

carlspring
carlspring

Reputation: 32597

If you have an artifact repository manager such as Nexus, Archiva, or Artifactory, you can deploy the jars to it. Then you can define them as dependencies in your pom.xml files.

If you don't, you can install them to your local repository using the maven-install-plugin using the install-file goal.

If you don't want to do that, there's also a not-recommended option of defining a dependency with <scope>system</scope> as illustrated here. Again, this is highly NOT recommended, as you would be expecting people would have the artifact on their file system and quite possibly, this jar might end up in your version control, which is really not the way to do it, but is also possible.

Upvotes: 3

arajashe
arajashe

Reputation: 291

answer is that others will not be able to build your code unless some conditions are met.. As mentioned by carlspring, you would have to either install to your own local repo or put a system scope dependency.

  • if you add it to your local repo, then your local would have to be some kind of common network writeable share/location that your entire team maps to in a standardized fashion in your development environment.
  • if you add a system scope dependency, you could actually put this jar into your codebase into a project relative lib directory and provide a path such as ${basedir}/lib/some.jar

Upvotes: 1

Related Questions