I have a proprietary jar that I want to add to my pom as a dependency.
But I don't want to add it to a repository. The reason is that I want my usual maven commands such as mvn compile
, etc, to work out of the box. (Without demanding from the developers a to add it to some repository by themselves).
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.
Can this be done? How?
Basically, add this to the pom.xml:
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. Thesystem
scoped should be avoided, such dependencies don't work well in many situation (e.g. in assembly), they cause more troubles than benefits.So, instead, declare a repository local to the project:
Install your third party lib in there using
install:install-file
with thelocalRepositoryPath
parameter:Update: It appears that
install:install-file
ignores thelocalRepositoryPath
when using the version 2.2 of the plugin. However, it works with version 2.3 and later of the plugin. So use the fully qualified name of the plugin to specify the version:maven-install-plugin documentation
Finally, declare it like any other dependency (but without the
system
scope):This is IMHO a better solution than using a
system
scope as your dependency will be treated like a good citizen (e.g. it will be included in an assembly and so on).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.
we switched to gradle and this works much better in gradle ;). we just specify a folder we can drop jars into for temporary situations like that. We still have most of our jars defined i the typicaly dependency management section(ie. the same as maven). This is just one more dependency we define.
so basically now we can just drop any jar we want into our lib dir for temporary testing if it is not a in maven repository somewhere.