tags:

views:

2598

answers:

2

Is there a way to compile multiple java source directories in a single maven project?

A: 

This worked for me

<build>
    <sourceDirectory>.</sourceDirectory>
    <plugins>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
        <includes>
            <include>src/main/java/**/*.java</include>
            <include>src/main2/java/**/*.java</include>
        </includes>
        </configuration>
        </plugin>
    </plugins>
</build>
sal
+11  A: 

You can add a new source directory with build-helper

  <plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>build-helper-maven-plugin</artifactId>
   <executions>
    <execution>
     <phase>generate-sources</phase>
     <goals><goal>add-source</goal></goals>
     <configuration>
      <sources><source>src/main/generated</source></sources>
     </configuration>
    </execution>
   </executions>
  </plugin>