Carl Shiles
Carl Shiles

Reputation: 444

Using Compile-Time Only Jars with Maven

I have a directory with a number of Jars that I need to compile my project, but I don't need for runtime. (They are already provided in the environment where war is being deployed.) These Jars are currently not associated with a Maven project.

What is the easiest way for me to include these jars so that a maven install will be successful? I saw that a maven dependency can have a scope of provided, but do I have to turn the Jars into Maven projects first?

Upvotes: 0

Views: 420

Answers (1)

Andrew S
Andrew S

Reputation: 2801

The dependent jars do not have to be turned into maven projects. Perhaps the easiest solution would be a one time task to manually publish those dependent jars to the repository so that your maven project can refer to them. Then as you mentioned, in your project mark those jars as provided.

However, this approach can lead to problems. For example, suppose your code relies on some Apache jars. How do you know which version of the Apache jars the run-time environment will provide? What if the run-time environment is updated but your code was compiled with an older jar with different package structure and/or class names? Class loader issues can be brutal. A WAR/EAR should be self-contained (as much as possible).

Upvotes: 1

Related Questions