5

I am using a dependency of scope "provided" pom file of an artifact. Because of "provided" scope, those dependency jars are not added in classpath of MANIFEST.MF.

Could you help me so that the jars should not be downloaded but should be added in classpath.

sridhar
  • 1,117
  • 5
  • 31
  • 59

1 Answers1

7

Well, if you want it semantically right, remove <scope>provided</scope> and leave it default (<scope>compile</scope>). Then set <optional>true</optional> for a dependency, so it will be included in manifest's classpath.

By using provided scope you actually say that you don't want it to be in manifest's classpath since it's anyway provided by the container.

Michał Kalinowski
  • 16,925
  • 5
  • 35
  • 48
  • many thanks Michal. I am using the above in EAR and I am referring a shared library in EAR. I could see jars are not downloaded but shared library jars are not referred. Could you help me about this. – sridhar Jun 20 '12 at 06:56
  • Sorry, I really don't understand you now. Can you explain your situation using maybe some `A`, `B` and `C` but say what is packaging of each of them and how look their dependencies. – Michał Kalinowski Jun 20 '12 at 07:00
  • Sure. I will do explain. Sorry for the confusion .. Michal. I am using maven. I have an artifact A of packaging type EJB. I have an artifact B of packaging EAR. I am using WAR shared library referrence in artifact B. I am using compile and true in artifact A because the required jar files are in shared library. With your help, I have added jar names in classpath of MANIFEST of EJB module but when deploying EAR file, I am getting classNotFound exception. this is the issue facing. – sridhar Jun 20 '12 at 07:04
  • @MichałKalinowski the only problem with your solution is you can not then use the dependencies analyze mojo on this maven module. IMHO the best solution is to create a new maven module with everything in scope **runtime.** – Tony Chemit Dec 14 '21 at 10:24