
Your project root should look something like this to start with: yourprojectĪdd a standard Maven repository directory called repo for the group com.example and version 1.0: yourproject

These parameters may not matter to you, but Maven requires this information for all dependencies. First you must define a groupId, artifactId and version for the library.

Let’s say your app depends on the library mylib.jar which is not in any public Maven repository. Pick groupId, artifactId and version parameters
MAVEN INSTALL A LOCAL JAR HOW TO
This guide shows you how to add these unmanaged libraries in your application project and tell Maven how to find them. Some Java applications have dependencies that aren’t available in a public or private Maven repository (the latter of which can be accessed using a custom settings.xml file). Create a local Maven repository directory.Pick groupId, artifactId and version parameters.To install more than one file, just add more executions. The meat of the pom.xml is in the build section where the maven-install-plugin is used. The pom packaging prevents this from doing any tests or compile or generating any jar file. The following are some snippets of the pom.xml file. The repository/pom.xml file will then contain the definitions to load up the JARs that are part of your project. You multi-module project pom.xml would look like this: pom

For this to work, you need to set up a multi-module project and have a new project representing the build to install files into the local repository and ensure that one is first. It also allows the file to reside anywhere in the project without fixing the names or following the maven repository structure. This also reduces the setup work by creating the POM and the SHA1 files as part of the build. This will get around the limit when using multi-module builds especially if the downloaded JAR is referenced in child projects outside of the parent. This is another method in addition to my previous answer at Can I add jars to maven 2 build classpath without installing them? However it is advisable that you install your jar in the repository, and not commit it to the SCM - after all that's what maven tries to eliminate. Now, I have to mention that the "right way" to deal with this situation in a corporate environment (maybe not the case here) would be to use a corporate repository. it will be included in an assembly and so on). This is IMHO a better solution than using a system scope as your dependency will be treated like a good citizen (e.g. So use the fully qualified name of the plugin to specify the version: mvn :maven-install-plugin:2.3.1:install-file \įinally, declare it like any other dependency (but without the system scope): However, it works with version 2.3 and later of the plugin. Update: It appears that install:install-file ignores the localRepositoryPath when using the version 2.2 of the plugin.

Mvn install:install-file -Dfile= -DgroupId= \ Install your third party lib in there using install:install-file with the localRepositoryPath parameter: So, instead, declare a repository local to the project: in assembly), they cause more troubles than benefits. The system scoped should be avoided, such dependencies don't work well in many situation (e.g. If you really want this (understand, if you can't use a corporate repository), then my advice would be to use a "file repository" local to the project and to not use a system scoped dependency. I want the jar to be in a 3rdparty lib in source control, and link to it by relative path from the pom.xml file.
