I am currently migrating our build process from Eclipse/Ant to Maven/M2Eclipse/Artifactory. I have a Webapp as a WTP project in Eclipse. I have migrated it to Maven with m2eclipse.
The compilation runs fine from the Eclipse IDE.
However, when I try to compile from Maven CLI (mvn clean & mvn compile
), Maven complains about not finding the libraries provided by the Tomcat Environment (like annotations-api, servlet-api, etc, ...).
Fair enough : Indeed, these dependencies are provided by WTP, as Java resources / Libraries / ApacheTomcat6
. Maven is not aware of them.
I could deactivate this in the build path, and add each corresponding dependency in my POM, but I'm afraid this would lead Maven to deploy them again in my webapp (WEB-INF/libs
).
So, what is the good way to say to maven "this application will run in a well known environment, providing the following libraries ". Is there some common Tomcat POM that I could add as a dependency ?
Thanks in advance for your advice. regards,
Raphael
One way to handle this is to declare these dependencies with scope provided
. These dependencies will be available for compile and test, but will not be packaged by maven into the webapp. For example,
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With