1

I'm new to Maven and I created a new web app to "migrate" an old application and to start using Maven 3. This application uses some libraries (jars) and most of them are under the shared/lib folder in Tomcat (5.5) directory.

How can add these libs to Maven POM? Should I add them at all?

I forgot to mention that some of these jars cannot be found in Maven repository since are more like utility libraries that are common to most of the projects.

Himanshu
  • 31,810
  • 31
  • 111
  • 133

2 Answers2

1

In the <dependencies/> section of the POM, you can declare the shared jar as a "system" scoped dependency. This scope recognizes a <systemPath/> child element, allowing you to point to the filesystem location on the local (build) filesystem.

See Maven "System" dependencies

example:

<project>
…
  <dependencies>
    <dependency>
      <groupId>com.example</groupId>
      <artifactId>someDependency</artifactId>
      <version>1.0.1</version>
      <scope>system</scope>
      <systemPath>${tomcatHome}/shared/lib/someDependency-1.0.1.jar</systemPath>
    </dependency>
  </dependencies>
…
</project>
Tommy Knowlton
  • 580
  • 1
  • 4
  • 15
  • This should work, thanks! However it now raises another question: When should I use system dependencies and when does it make sense to create/use a local repo? – Jose Ramirez Nov 21 '12 at 12:48
  • I worked in an organization where we had several interdependent projects, and we "mavenized" them all at once - which was a huge undertaking. If I were in the same position again, I might choose an incremental approach, moving just one product into maven's ecosystem, and use "system" scope reps for the others. Then, as your collection of products evolves and you get more into maven, you can change the dependent poms to reflect that evolution. – Tommy Knowlton Nov 22 '12 at 17:54
  • I got your point, I'll take one step at a time. Thanks for the advice. – Jose Ramirez Nov 23 '12 at 00:29
0

Use

 <dependency>

tags to specify the libraries. And if some of the libraries are not found in the maven repository. Specify the repository using

<configuration>
Shamis Shukoor
  • 2,515
  • 5
  • 29
  • 33