0

I have a custom list of jars around 40 jars in a libs folder. I want to add all as a maven dependenices.

+ project
  pom.xml
  + src
  + libs

Is there any way by that add all jar at a time.

Mayank Pandya
  • 1,593
  • 2
  • 17
  • 40
  • possible duplicate of [Can I add jars to maven 2 build classpath without installing them?](http://stackoverflow.com/questions/364114/can-i-add-jars-to-maven-2-build-classpath-without-installing-them) – Bala Sep 25 '14 at 17:17

2 Answers2

0

Maven manages dependencies rather different than just including jars.

Essentially if you have a dependency on A and A uses B, you will need to have both A+B in your lib folder, but only A in your maven project, because maven transitively will include the subdependencies.

You should probably look through the maven repository, and see if you can find the jar files there in a similar version, and include that instead.

i.e. if you have commons-collections4-4.0.jar, use http://search.maven.org and write commons-collections4, and you will see a list of candidates. probably some with multiple version. Note, maven uses a groupId to scope jar files, so pick one with a suitable groupId, in this case org.apache.commons (Since commons-collections is an apache.org project).

When you have identified your dependency, it will show you ways to include it in your build, e.g. for maven, it would be

<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-collections4</artifactId>
    <version>4.0</version>
</dependency>

Looking at the pom file, you will be able to spot potential subdependencies, but otherwise, once you have added the dependency to your <dependencies/> section of your pom, run a mvn dependency:tree or mvn dependency:list to see how dependencies are transitively included.

Should you end up with libraries you cannot find in maven central, read this guide for the rest http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Niels Bech Nielsen
  • 4,777
  • 1
  • 21
  • 44
0

Found one wonderfull plugin to achieve this task. addjars-maven-plugin

Mayank Pandya
  • 1,593
  • 2
  • 17
  • 40