Changing Source and Resource Directories in Maven

When moving a legacy project from Ant to Maven, I needed to change the default source (default: src/[main|test]/java) and resources (default: src/[main|test]/resources) directories in Maven. These settings may be configured in the <build> element of the project’s pom.xml.

  • <sourceDirectory> the directory where the sources of your application are stored
  • <testSourceDirectory> the directory where the sources of your test cases are stored
  • <resources> the resources of your main application
  • <testResources> the resources needed only by your test cases

The relevant part of the pom.xml in Maven 2.1.x and above looks like this (with default values):

Links

1 comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box