Including and excluding source files and folders

As per Maven conventions, all project sources should be in the src folder. However, there may be legacy projects that are organized differently and may have more than one source folder. Also, in some projects, we might generate sources dynamically from tools such as wsdl2java. In such cases, Maven needs to be told about these additional source folders. Note that such projects may not work well in IDEs.

How to do it...

Use the following steps to include and exclude source files and folders in your Maven project:

  1. Open the Maven project named project-with-additional-source.
  2. Add the following section in the pom file:
     <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>build-helper-maven-plugin</artifactId> ...

Get Apache Maven Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.