Anand B
Anand B

Reputation: 3085

install all jars in folder using maven-install-plugin

I have a folder lib in my project with some external jars. I am using maven-install-plugin to add these jars in to my local reposotory. However I need to create a seperate configuration for every jar to be installed. Is there a way by which I can copy all the jars in lib folder in to local repository.

Upvotes: 3

Views: 4216

Answers (2)

theon
theon

Reputation: 14380

Option One

If the contents of the lib directory, matches the directory structure in a maven repository, i.e:

/lib/{groupid1}/{groupid2}/{artifactid}/{version}/{artifactid}-{version}.jar

For example:

/lib/commons-lang/commons-lang/2.6/commons-lang-2.6.jar 

you can just copy the whole directory to your ~/.m2/repository directory

cp -R lib/*  ~/.m2/repository

If not, then you have to install them one by one manually, because Maven has no way of working out what the group id is purely from the filename.

Option Two

Another option would be to not put them into you local repository at all and instead specify a systemPath in your dependency tags in your pom.xml

<dependency>
  <groupId>commons-logging</groupId>
  <artifactId>commons-logging</artifactId>
  <version>1.0.4</version>
  <scope>system</scope>
  <systemPath>${project.basedir}/lib/commons-logging-1.0.4.jar</systemPath>
</dependency>

Upvotes: 2

khmarbaise
khmarbaise

Reputation: 97399

You need to give in particular the groupId, artifactId and version of those file, cause these are the Maven coordinates to distinguish the artifacts in Maven. If you have a lib folder better start using a repository manager and install them into the repository manager once and afterwards you can use them as usual dependencies.

Upvotes: 1

Related Questions