StickStack
StickStack

Reputation: 55

How to define source folder order in maven pom file?

How can I define the source folder order in my maven pom file? I am currently using the standard maven directory layout but whenever I run the command "mvn eclipse:eclipse" the source folder order is as follows:

  1. src/test/java
  2. src/test/resources
  3. src/main/java
  4. src/main/resources

How can I have it set to:

  1. src/main/java
  2. src/main/resources
  3. src/test/java
  4. src/test/resources

The class path file generated also has the test folders before the main folders.

Upvotes: 4

Views: 1083

Answers (2)

To get the order you prefer, add this to your pom.xml:

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-eclipse-plugin</artifactId>
      <version>2.10</version><!-- correct version for you? -->
      <configuration>
        <testSourcesLast>true</testSourcesLast>
      </configuration>
    </plugin>
  </plugins>
</build>

Upvotes: 5

prunge
prunge

Reputation: 23238

This is intentional, because when running unit tests under Maven with the surefire plugin, test classes and resources come before the main classes and resources in the classpath. This allows test resources to override the main ones, for example a log4j.properties file to have different logging settings for testing than in the standard build.

Additional:

Surefire (since 2.0.8) classpath order described here: http://jira.codehaus.org/browse/MNG-3118

Upvotes: 1

Related Questions