1

I was having a dynamic webapplication created on eclipse. I converted it to a maven project using M2E plugin. I added maven war plugin in the pom.xml so that it can create war for my project using maven build.

But when I do the build, it fails to compile few classes which has reference to the jars of my webapp/Web-INF/lib folder. These jars I can't include as dependency in pom.xml.

How can I tell maven to include Web-INF/lib jars also while building classes and creating a war?

Neeraj
  • 1,776
  • 2
  • 16
  • 35
  • 1
    How those jars are present in WEB-INF/lib ?? Upto my understanding after maven-war-plugin execution it puts all the jars in WeB-INF/lib folder, so how it can contain jars before build starts. And can you please provide the error that you are getting while executing maven-wasr-plugin ?- Thanks – saurav Aug 01 '13 at 06:44
  • Actually I have put that jar in WEB-INF/lib folder. Basically I want to include a jar for build which is not available on maven repository. I can keep it in some other folder and include it if needed instead of WEB-INF/lib folder. I get compilation error in one of the class as maven build not including my jar. – Neeraj Aug 01 '13 at 06:48

1 Answers1

1

Its not correct way of doing this , you should not put any jar manually in WEB-INF/lib folder.

And if that jar is not available in MAVEN CENTRAL REPO , then you can download it and install it in your NEXUS CENTRAL REPO (if you have any) otherwise put that jar in your local maven repository and add it as a dependency in your pom file. If you don't want to include that jar in your WEB-INF/lib then change the scope to provided otherwise leave it as default i.e compile.

During build time MAVEN will look for that particular jar in your local repo first , and if it don't find it there then it try to download from Centra Repo.

Once it is available in your local repo , your build won't break.

Andrew Barber
  • 39,603
  • 20
  • 94
  • 123
saurav
  • 3,424
  • 1
  • 22
  • 33
  • Thanks, your answer really helped. We need to create local repository for that jar. But what if I have to give this webapp to someone. How he will get that dependency? As that dependency is local. Are there any sites which allow to upload your dependencies? – Neeraj Aug 01 '13 at 07:19
  • What actually that mean `if I have to give this webapp to someone ?`. Are you talking about giving the war file ? - Thanks – saurav Aug 01 '13 at 07:30
  • Oops - yes I mean same :). Or giving this application to another developer for development. – Neeraj Aug 01 '13 at 08:57
  • in that case better to have a Nexus repository , otherwise development is going to be cumbersome. And can you give me the detail of that jar , is it external or your internal project related jar. - Thanks – saurav Aug 01 '13 at 12:00