Saturday, February 4, 2012

No such compiler 'groovy-eclipse-compiler'

I have a maven project with a groovy REST interface running inside Jetty. The groovy-eclipse-compiler will compile the groovy code into Java code.

Sounds simple and the codehaus page for the plugin makes it look even simpler. But when I ran mvn jetty:run, which should have rebuilt the entire app for me before deploying to jetty, I received this error:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project cellers: No such compiler 'groovy-eclipse-compiler'. -> [Help 1]


What bullshit. That's what you're thinking, right?

But what I missed is that when changing/adding compilers, which is effectively what you're doing here, the new compiler needs to be a dependency of the maven-compiler-plugin.

  <build>
    <finalName>cellers</finalName>
    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.0.4.v20111024</version>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>2.3.2</version>
        <configuration>
          <compilerId>groovy-eclipse-compiler</compilerId>
          <verbose>true</verbose>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-eclipse-compiler</artifactId>
            <version>2.6.0-01</version>
          </dependency>
        </dependencies>
      </plugin>
    </plugins>
  </build>