Skip to content

[MCOMPILER-572] Multi-line <arg> does not work on Windows when forked #784

Description

@jira-importer

Mikkel Kjeldsen opened MCOMPILER-572 and commented

Versions of maven-compiler-plugin that rely on plexus-compiler-2.14.2, hereunder maven-compiler-plugin-3.12.1, cannot pass multi-line compiler arguments to a forked javac on Windows in any way. Further, attempting to do so produces a non-obvious and difficult to troubleshoot error. This error does not manifest outside of Windows, nor does it manifest on Windows if the compiler is not forked.

This bug is a downstream version of codehaus-plexus/plexus-compiler#351, filed in response to google/error-prone#4256.

The sample POM

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>example.multi-line-fork-crash</groupId>
  <artifactId>minimally-reproducible</artifactId>
  <version>1.0-SNAPSHOT</version>
  <properties>
    <maven.compiler.release>21</maven.compiler.release>
    <maven-compiler-plugin.version>3.12.1</maven-compiler-plugin.version>
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <fork>true</fork>
          <compilerArgs>
            <arg>
              -Xplugin:ErrorProne \
              -Xep:DeadException:WARN</arg>
          </compilerArgs>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

should fail to compile with the error

plug-in not found: ErrorProne

but instead fails with the error

error: invalid flag: -Xep:DeadException

because plexus-compiler indiscriminately translates the \ to / and breaks javac 's multi-line argument support.


Affects: 3.12.1

Issue Links:

  • MCOMPILER-425 Compiler argument with newline treated as multiple arguments in fork mode

Remote Links:

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.xbugSomething isn't workingpriority:majorMajor loss of function

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions