36

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?

Ralph
  • 118,862
  • 56
  • 287
  • 383

2 Answers2

55

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

Ralph
  • 118,862
  • 56
  • 287
  • 383
  • For me it was sufficient to just exclude any `src/test` folders from `Deployment Assembly`. – membersound May 06 '14 at 09:32
  • This workaround works if you do not need to change maven profiles. I've got a project configured with maven profiles and whenever I change them, m2e reconfigures the deployment assembly and I need to go and edit it again. – Pavel Nov 15 '14 at 14:09
  • How do I exclude folders? I can only "add" ... – DavidDunham Mar 16 '22 at 06:46
  • @DavidDunham: are you talking about **subfolders** in one of the folders listed in that dialog? – Ralph Mar 16 '22 at 19:22
7

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

Jeff
  • 956
  • 8
  • 10