How to solve Element compilerArgs is not allowed here Error in maven compiler plugin?

patrik picture patrik · Nov 17, 2017 · Viewed 8.4k times · Source

I am using the maven compiler plugin 3.0 and I get the error "Element compilerArgs is not allowed here". This seems to work for command line but I get this Error in the IDE,.I use IDEA 2017.2 community edition. There is likely some schema missing somewhere, but I am not sure. Does anyone have a good way to solve issues like this, that is not to send a bug report to JetBrains and wait for a fix?

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.0</version>
    <configuration>
        <source>1.7</source>
        <target>1.7</target>
        <fork>true</fork>
        <compilerArgs>
            <arg>-DspecificArg</arg>
        </compilerArgs>
    </configuration>
</plugin>

Answer

Stefan picture Stefan · Nov 17, 2017

I suggest you try maven-compiler-plugin version 3.7.0.

If you stay on version 3.0, update your setup so it looks like this example: http://maven.apache.org/plugins-archives/maven-compiler-plugin-3.0/examples/pass-compiler-arguments.html

If you can go up to 3.7.0, take a look at this example (which is very similar to your code): https://maven.apache.org/plugins/maven-compiler-plugin/examples/pass-compiler-arguments.html#