36
votes

I have a Maven project, containing the typical folders src/main/java and src/test/java and I am using Eclipse 3.7 with m2e 1.0.and Maven Integration for WTP 1.4.0 . Eclipse is used during development to deploy the application on an server (Tomcat or Glassfish), but it deploys the test classes from src/test/java folder too.

I do not want the test classes deployed, so how can I "exclude" that directory from eclipse-tomcat deployment?

2
Have you installed m2e plugin and m2e WTP in your Eclipse ? - khmarbaise
@khmarbaise Sorry, I forgot this information: I am using m2e 1.0.100 - Ralph
I asked if you have installed m2e for WTP ? Can you post your pom? - khmarbaise
@khmarbaise Sorry, yes I have it: Maven Integration for WTP version 1.14.0 - Ralph
What does Deployment Assembly in the project Properties show? It should not have src/main/test. - Raghuram

2 Answers

54
votes

It is configurable in Eclipse how to handle and deploy the different folders, somehow the Eclipse plugin M2Eclipse should configure Eclipse right, it seams that the configuration sometimes is done and sometimes not.

So one has to check this two settings:

  • Project Properties\Java Build Path(Tab)Source : Outputfolder for <PROJECT>/src/test/java as well as <PROJECT>/src/test/resources must be <PROJECT>/target/test-classes

  • Project Properties\Deployment Assembly : There must be NO entry for <PROJECT>/src/test/java or <PROJECT>/target/test-classesenter image description here

7
votes

When this happens, perform "Maven -> Update Project..." from the project properties context menu. In my experience, this correctly reconfigures Eclipse.