Skip to end of metadata
Go to start of metadata

Compiling your Groovy sources

The compilation goals (including those for joint compilation) for GMavenPlus are bound to their respective phases in the build lifecycle. So to compile your sources, you need only tell maven how much of the lifecycle to execute. The following will compile your sources:

mvn compile

To compile your test sources, you'll do:

mvn test-compile

The above command will execute both compiler:compile and compiler:testCompile since the compile phase happens a few phases before the test-compile phase.

Configuring GMavenPlus

<project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.gmavenplus</groupId>
        <artifactId>gmavenplus-plugin</artifactId>
        <version>1.2</version>
        <executions>
          <execution>
            <goals>
<goal>addSources</goal>
<goal>addTestSources</goal>
<goal>generateStubs</goal> <goal>compile</goal> <goal>testGenerateStubs</goal> <goal>testCompile</goal>
 <goal>removeStubs</goal>

 <goal>removeTestStubs</goal>
</goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> </plugin> <
plugin>
        <!-- if including source jars, use the no-fork goals
otherwise both the Groovy sources and Java stub sources will get included in your jar -->
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar-no-fork</goal>
              <goal>test-jar-no-fork</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
</plugins> </build> <dependencies> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <!-- any version of Groovy \>= 1.8.2 should work here --> <version>2.3.7</version> </dependency> </dependencies> </project>

  • No labels

1 Comment

  1. Note that Groovy 1.7.1 seems to cause errors.  The error I saw in my integration test suite was

    [ERROR] Failed to execute goal on project gmavenplus-plugin-it-basicCompile: Could not resolve dependencies for project org.codehaus.gmavenplus:gmavenplus-plugin-it-basicCompile:jar:testing: Failure to find org.fusesource.jansi:jansi:jar:1.1 in file:///C:/Users/Keegan/.m2/repository was cached in the local repository, resolution will not be reattempted until the update interval of local.central has elapsed or updates are forced -> [Help 1]

    This can be avoided by adding this exclusion to your Groovy dependency

    <exclusion>
      <groupId>org.fusesource.jansi</groupId>
      <artifactId>jansi</artifactId>
    </exclusion>

    Or just use a different version of Groovy.  This is caused by some bad dependencies that were added to that particular version of Groovy.  See this conversation.