Then you can add the dependency into your pom.xml Let’s consider that the jar is located under _ /lib/app.jar._ Below the configuration of maven-install-plugin: The best way is to put the JAR in a folder created at the root of the project (in the same directory as the pom.xml file). To do this, you must specify the location of the jar you want to install.
The portability of the project must be taken into account.Īnother solution is to use the _maven-install-plugin_ in your _pom.xml_ which will install the jar during the Maven _“initialize”_ phase. Or again, if there are many persons working on the project, each must install the JAR in his local repository. Why ? You have to consider that the day you change your local Maven repository you have to re-install the JAR. You can then add the dependency to your Maven project by adding those lines to your pom.xml file: These information can also be given in command line: mvn install:install-file -Dfile= -DgroupId= -DartifactId= -Dversion=įor example: mvn install:install-file –Dfile=C:\dev\app.jar -DgroupId= -DartifactId=example-app -Dversion=1.0 Indeed, since the version 2.5 of _ Maven-install-plugin_, these information can be taken from an optionally specified _pomFile_. Note that we didn’t specify _groupId_, artifactId, version and packaging of the JAR to install.
The use of the plugin is very simple as below: mvn install:install-file -Dfile= The first solution is to add manually the JAR into your local Maven repository by using the Maven goal _ install:install-file_.
You may need to add a custom JAR as a dependency to your Maven project.