Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using IDEA with maven2, how to add a non-maven .jar?

I have a .jar that I want included in my IDEA web application project that is using maven2 (pom.xml).

How can I add a .jar to my project that isn't using maven?

like image 347
Blankman Avatar asked Dec 03 '22 12:12

Blankman


2 Answers

You basically have three options:

  • Install the jar in your local repository using install:install-file (see Guide to installing 3rd party JARs). This is pretty straightforward and easy but this will make your POM non portable. This might be an option if you are alone and doesn't plan to distribute your pom.xml.

  • Deploy the jar in a corporate repository using deploy:deploy-file. This is of course the ideal and preferred scenario in a corporate environment.

  • If you're not using a corporate repository but are still working in team, setup a file based repository and share it through your source repository.

like image 111
Pascal Thivent Avatar answered Dec 25 '22 20:12

Pascal Thivent


Easiest thing is to use maven:install-file to install the jar in your local repository, as follows (stolen from the docs:

mvn install:install-file -Dfile=path-to-non-maven.jar \
                      -DgroupId=some-id \
                      -DartifactId=some-artifact \
                      -Dversion=some-version \
                      -Dpackaging=jar

Then add it to your POM like any other dependency. If it needs to be shared with many people, you may consider setting up a local instance of something like Nexus or Artifactory (we use Artifactory where I work and it works well).

like image 21
ig0774 Avatar answered Dec 25 '22 20:12

ig0774