maven-compiler-plugin icon indicating copy to clipboard operation
maven-compiler-plugin copied to clipboard

[MCOMPILER-514] Cant stack compiler plugin argument variations

Open jira-importer opened this issue 3 years ago • 1 comments

Delany opened MCOMPILER-514 and commented

This works

<compilerArgs>
  <arg>-Xlint:all,-processing</arg>
  <arg>-Xlint:all</arg>
  <arg>-XDcompilePolicy=byfile</arg>
  <arg>-Xplugin:ErrorProne</arg>
  <arg>-Xplugin:ErrorProne</arg>
</compilerArgs>

But this

<compilerArgs>
  <arg>-Xlint:all,-processing</arg>
  <arg>-Xlint:all</arg>
  <arg>-XDcompilePolicy=byfile</arg>
  <arg>-Xplugin:ErrorProne</arg>
  <arg>-Xplugin:ErrorProne -XepDisableAllChecks</arg>
</compilerArgs>

fails with this

[ERROR] org.apache.maven.cli.MavenCli - plug-in not found: ErrorProne

There is no problem stacking -Xlint argument variations, or stacking the -Xplugin argument (provided the argument is the same.) But it dies when the -Xplugin argument varies. Why should this be?

Use case? I have separate profiles for activating various errorprone bugpatterns. I want a default configuration in place unless I activate one of these profiles. I dont want to have to edit source code every time to check a different bugpattern.


Affects: 3.10.1

jira-importer avatar Dec 09 '22 07:12 jira-importer

Delany commented

Ok here's my workaround

<properties>
  <build.ep>-Xep:SuppressWarningsWithoutExplanation:WARN</build.ep>
</properties>
...
<compilerArgs combine.children="append">
  <arg>-Xlint:all,-processing</arg>
  <arg>-XDcompilePolicy=byfile</arg>
  <arg>-Xplugin:ErrorProne -XepDisableAllChecks ${build.ep}</arg>
</compilerArgs>
...
<profile>
  <id>EPE</id>
  <activation>
    <property>
      <name>EPE</name>
    </property>
  </activation>
  <properties>
    <build.ep>-Xep:${EPE}:ERROR</build.ep>
  </properties>
</profile>
<profile>
  <id>EPW</id>
  <activation>
    <property>
      <name>EPW</name>
    </property>
  </activation>
  <properties>
    <build.ep>-Xep:${EPW}:WARN</build.ep>
  </properties>
</profile>
<profile>
  <id>EPP</id>
  <activation>
    <property>
      <name>EPP</name>
    </property>
  </activation>
  <properties>
    <build.ep>-XepPatchLocation:IN_PLACE -XepPatchChecks:${EPP}</build.ep>
  </properties>
</profile>

Then if I want the build to fail with DefaultCharset violations

./mvnw -DEPE=DefaultCharset 

jira-importer avatar Dec 09 '22 08:12 jira-importer