title: Compile error combining groovy and java (using maven)
body: <p>I want to use groovy for my domain object to get rid of boilerplate code of setter/getters and so on.
  But I have a issue with using AST transformations, particularly with generated constructors.</p>
  <p>Here some minimum code for reproduction:</p>
  <h2>App.java</h2>
  <pre><code>package experiment.groovy;
  
  public class App {
      public static void main(String[] args) {
          Example example = new Example(&quot;Alex&quot;);
          System.out.println(example.getName());
      }
  }
  </code></pre>
  <h2>Example.groovy</h2>
  <pre><code>package experiment.groovy
  
  import groovy.transform.Canonical
  
  @Canonical
  class Example {
      String name;
      int id;
  }
  </code></pre>
  <h2>Project structure</h2>
  <p><a href="https://i.stack.imgur.com/85TOM.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/85TOM.gif" alt="" /></a></p>
  
  <h2>pom.xml</h2>
  <pre><code>&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot; 
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=
  &quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
      &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;
      &lt;groupId&gt;experiment.groovy&lt;/groupId&gt;
      &lt;artifactId&gt;groovy-ast&lt;/artifactId&gt;
      &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
      &lt;dependencies&gt;
          &lt;dependency&gt;
              &lt;groupId&gt;org.codehaus.groovy&lt;/groupId&gt;
              &lt;artifactId&gt;groovy-all&lt;/artifactId&gt;
              &lt;version&gt;2.3.0&lt;/version&gt;
          &lt;/dependency&gt;
      &lt;/dependencies&gt;
      &lt;build&gt;
          &lt;plugins&gt;
              &lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.gmaven&lt;/groupId&gt;
                  &lt;artifactId&gt;gmaven-plugin&lt;/artifactId&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;generateStubs&lt;/goal&gt;
                              &lt;goal&gt;compile&lt;/goal&gt;
                              &lt;goal&gt;generateTestStubs&lt;/goal&gt;
                              &lt;goal&gt;testCompile&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
          &lt;/plugins&gt;
      &lt;/build&gt;
  &lt;/project&gt;
  </code></pre>
  <p>I also tried with <code>groovy-eclipse-compiler</code>:</p>
  <pre><code>&lt;build&gt;
      &lt;plugins&gt;
          &lt;plugin&gt;
              &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
              &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt;
              &lt;version&gt;3.1&lt;/version&gt;
              &lt;configuration&gt;
                  &lt;compilerId&gt;groovy-eclipse-compiler&lt;/compilerId&gt;
                  &lt;source&gt;1.7&lt;/source&gt;
                  &lt;target&gt;1.7&lt;/target&gt;
              &lt;/configuration&gt;
              &lt;dependencies&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.codehaus.groovy&lt;/groupId&gt;
                      &lt;artifactId&gt;groovy-eclipse-compiler&lt;/artifactId&gt;
                      &lt;version&gt;2.8.0-01&lt;/version&gt;
                  &lt;/dependency&gt;
                  &lt;dependency&gt;
                      &lt;groupId&gt;org.codehaus.groovy&lt;/groupId&gt;
                      &lt;artifactId&gt;groovy-eclipse-batch&lt;/artifactId&gt;
                      &lt;version&gt;2.1.8-01&lt;/version&gt;
                  &lt;/dependency&gt;
              &lt;/dependencies&gt;
          &lt;/plugin&gt;
      &lt;/plugins&gt;
  &lt;/build&gt;
          
  </code></pre>
  <p>And <code>mvn compile</code> failing with error.</p>
  <pre><code>1. ERROR in C:\DEV\Groovy\src\main\java\experiment\groovy\ZApp.java (at line 5)
  [ERROR] COMPILATION ERROR : 
      Example example = new Example(&quot;ToDelete&quot;);
  [INFO] -------------------------------------------------------------
                        ^^^^^^^^^^^^^^^^^^^^^^^
  [ERROR] Found 1 error and 0 warnings.
  The constructor Example(String) is undefined
  </code></pre>
  <p>So the question is: what should I change, OR, may be, it is impossible?</p>
  <p>P.S. In future, if it is important, I will add <code>javax.persistence.Entity</code> annotation to the Example class.</p>