Can maven treat WEB-INF\lib the way eclipse (and m2e) does?

1.7k Views Asked by At

I have a servlet/jsp web project which runs fine on eclipse and is exported as war fine (once I clean it that is). I mavenized the project deleting all of the dependencies from the WEB-INF\lib folder except a homebrew jar (the output of another project in the workspace). When I run the package maven goal I get messages for missing classes from this jar:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers does not exist

Now this has been asked before and the most rigorous solution appears to be to create a local repo: Can I add jars to maven 2 build classpath without installing them? (NB: I am at maven 3).

I would like to avoid this - so is there any way maven will just stuff this jar to WEB-INF\lib in the war ?

Solutions that use some maven plugin to cp the contents of the WEB-INF\lib in the war are welcome - although I just have this feeling that there should be a solution that takes into account the "special" nature of this folder.

Observations:

  • Alt+F5 removes this line:

    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    

    which corresponds to the "Web App libraries" in the Java Build Path. So not only maven refuses to take into account the WEB-INF\lib - it also breaks the build path of eclipse completely.

Related:

1

There are 1 best solutions below

2
On

Did you add this jar from WEB-INF\lib as a dependency like this:

<dependency>
  <groupId>someGroupId</groupId>
  <artifactId>someArtifactId</artifactId>
  <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/homebrew jar</systemPath>
</dependency>