0

I was using eclipse for building my project. Now I am configuring the project to Maven project. All the libs were manually downloaded to lib folder. If I do a Maven build, Maven is unable to map those libs. There are lots of libs, I don't want to manually place them in pom.xml. What is the best way out?

I have read few answers, first declare local repo and then add the respective dependencies. But again I don't want to add all the dependencies manually.

Maven: best way of linking custom external JAR to my project?

Community
  • 1
  • 1
Forkmohit
  • 733
  • 3
  • 12
  • 31
  • As far as I know, you need all of your dependencies in the pom.xml so you'll need to add them there. Maybe you can write a script that reads all the jar filenames and have it output the XML you need to add to your pom.xml ? – Stefan Mar 30 '15 at 06:49
  • I got this script from one of the answers: https://github.com/nikita-volkov/install-to-project-repo But its not able to parse all the libs. – Forkmohit Mar 30 '15 at 06:51
  • Either modify it so it works for you or create your own script that outputs the required XML. :) – Stefan Mar 30 '15 at 06:53
  • 1
    Okay u mean pom.xml MUST have dependencies declared? – Forkmohit Mar 30 '15 at 06:53
  • As far as I know, yes. – Stefan Mar 30 '15 at 06:54

1 Answers1

0

1.) Install locally

There are two scopes which are interesting for you. If you declare a scope "runtime" (which is the default scope) and have a local repository configured, maven will try to download the file from your local repository.

2.) System dependency

If you just don't want maven to manage dependencies, you can (although shan't) use the system scope like this:

<dependency>
    ...
    <scope>system</scope>
    <systemPath>/path/to/dependency.jar</systemPath>
</dependency>

The downsides are:

  • the system scope is deprecated and might not work in future versions of maven.
  • you need to check in a jar file, which is not a good idea.
  • it may not be portable (e.g. architecture dependent libraries).
Community
  • 1
  • 1
Benjamin Marwell
  • 1,173
  • 1
  • 13
  • 36