Piotr Tempes
Piotr Tempes

Reputation: 1161

How to configure maven and intellij to include parameters compiler flag for both groovy and java

Hey I am writing this since I spent some time trying to configure Jackson's ObjectMapper to work without @JsonCreator and @JsonProperty annotations on my DTOs. The result I wanted to achieve is to be able to run Spock's tests (groovy) in both intellij and in console with maven.

Upvotes: 0

Views: 916

Answers (1)

Piotr Tempes
Piotr Tempes

Reputation: 1161

Since this issue is resolved: https://youtrack.jetbrains.com/issue/IDEA-125737 intellij automatically picks up below maven configuration:

<plugin>
   <groupId>org.apache.maven.plugins</groupId>
   <artifactId>maven-compiler-plugin</artifactId>
   <configuration>
      <compilerArgument>-parameters</compilerArgument>
      <testCompilerArgument>-parameters</testCompilerArgument>
   </configuration>
</plugin>

Also if you want to use Spock for testing in groovy you need following plugin configuration:

<plugin>
    <groupId>org.codehaus.gmavenplus</groupId>
    <artifactId>gmavenplus-plugin</artifactId>
    <version>${gmavenplus-plugin.version}</version>
    <configuration>
        <parameters>true</parameters>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
                <goal>compileTests</goal>
            </goals>
        </execution>
    </executions>
</plugin>

plus additional information:

  1. At the moment I was writing this there was only one version of groovy compiler that worked for me: 2.5.0-alpha-1
  2. maven-compiler-plugin version I used was 3.7.0. Version 3.1 did not work at all. I did not try others.

I hope this saves someone some time :)

Upvotes: 1

Related Questions