Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Groovy file does not compile in Intellij IDEA

I have maven project wit java and groovy tests. In command line maven compilation all tests are running, but in my IDEA project (which is created automatically, by "AutoImport maven projects", IDEA copies groovy files to /target/test-classes without compiling them.

My gmaven plugin looks like

    <plugin>
                <groupId>org.codehaus.gmaven</groupId>
                <artifactId>gmaven-plugin</artifactId>
                <version>1.3</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generateStubs</goal>
                            <goal>compile</goal>
                            <goal>generateTestStubs</goal>
                            <goal>testCompile</goal>
                        </goals>
                        <configuration>
                            <providerSelection>1.7</providerSelection>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.groovy</groupId>
                        <artifactId>groovy-all</artifactId>
                        <version>${groovy.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
like image 762
Pavel Bernshtam Avatar asked Nov 29 '11 12:11

Pavel Bernshtam


People also ask

Does IntelliJ support Groovy?

The Groovy plugin is bundled with IntelliJ IDEA and enabled by default. IntelliJ IDEA supports the latest stable version of Groovy and Groovy 4 syntax.

Does Groovy compile?

The Groovy compiler seems to compile directly from source to bytecode: groovyc is the Groovy compiler command line tool. It allows you to compile Groovy sources into bytecode. It plays the same role as javac in the Java world.


2 Answers

I had the same issue and had to change in Idea the following setting: Settings->Compiler->Resource patterns

It was !?*.java

I changed it into !?.java;!?.form;!?.class;!?.groovy;!?.scala;!?.flex;!?.kt;!?.clj

It would be better to be able to specify it into the pom file though but haven't found a way yet.

like image 96
Kim D. Avatar answered Oct 19 '22 10:10

Kim D.


GMaven plugin is only intended for maven compilation. Idea uses the Groovy compiler included in groovy-all jar. For Idea to get a hold of that add a project dependency, e.g.:

...
  <groupId>yourproject</groupId>
  <artifactId>yourproject</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <dependencies>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>${groovy.version}</version>
    </dependency>
  </dependencies>
...
like image 5
Nikita Volkov Avatar answered Oct 19 '22 11:10

Nikita Volkov