Tagged "maven"

Configuring Eclipse source directories with maven

When you generate a Java project using maven and then import it into Eclipse, often you want to add extra directories that are treated as source directories. This guide will show you how to do it.

First lets look at (a snippet of) the Super POM to see what we get by default:

<build>
  <sourceDirectory>src/main/java</sourceDirectory>
  <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
  <testSourceDirectory>src/test/java</testSourceDirectory>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
  </resources>
</build>

We can override what we get from here which is probably what you’ll do most of the time; adding another resource directory. When you add another resource remember that you’re overriding the default so if you still want src/main/resources then you’ll have to explicitly add it.