views:

299

answers:

1

I'm using the GMAven plugin to create Java stubs which successfully compiles my project (Java code that references Groovy).

After the stubs have generated I create an Eclipse project (mvn eclipse:eclipse) but the stubs are included on the classpath so rather than my Groovy getting executed (when debugging in Eclipse) the Java stubs are as they are included in the project.

Is there any way to either remove the stubs as a part of the build process or get Eclipse to ignore them? I'm not having any luck with "sourceExcludes" on the maven-eclipse-plugin.

Thanks for any insight.

+2  A: 

You can remove src/main/java from the Eclipse classpath so the java types are not compiled by Eclipse.

To do so, open the project properties (alt+enter), then select Java Build Path->Source, select the src/main/java folder and select Remove.

Alternatively, you could use the maven-antrun-plugin to delete the offending folder before the compile phase.

(updated to reflect comment) The configuration below will delete src/main/java during the package phase, i.e. after the Java compilation occurs:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <phase>package</phase>
      <configuration>
        <tasks>
          <delete dir="${basedir}/src/main/java"/>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Rich Seller
Thanks for the quick response. Does exactly what I need. I changed the phase to after compile (package) as I need the Groovy stubs for Java compilation.