Cosium / git-code-format-maven-plugin

A maven plugin that automatically deploys code formatters as pre-commit git hook

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-code-format-maven-plugin Java 17 maven plugin Error

BilgehanYildiz opened this issue · comments

Hi I want to run git-code-format-maven-plugin in Java17 without giving any jvm parameters to command line(https://github.com/google/google-java-format/releases/tag/v1.10.0).For that reason I added necessary jvm flags to maven compiler plugin but still got error
How can we use git-code-format-maven-plugin with pom.xml configurations only

class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x26bd2d7d) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.parser to unnamed module @0x26bd2d7d

    <plugin>
      <groupId>com.cosium.code</groupId>
      <artifactId>git-code-format-maven-plugin</artifactId>
      <version>${git-code-format-maven-plugin.version}</version>

      <executions>
        <!-- On Maven verify phase, fail if any file
        (including unmodified) is badly formatted -->
        <execution>
          <id>validate-code-format</id>
          <goals>
            <goal>validate-code-format</goal>
          </goals>
        </execution>
      </executions>
      <dependencies>
        <!-- Enable https://github.com/google/google-java-format -->
        <dependency>
          <groupId>com.cosium.code</groupId>
          <artifactId>google-java-format</artifactId>
          <version>${git-code-format-maven-plugin.version}</version>
        </dependency>
      </dependencies>
    </plugin>



  </plugins>
</pluginManagement>

<plugins>
  <plugin>
    <groupId>com.cosium.code</groupId>
    <artifactId>git-code-format-maven-plugin</artifactId>
  </plugin>
  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>${maven.compiler.version}</version>
    <configuration>
      <!--<release>${maven.compiler.target}</release>-->


        <compilerArgs>
          <arg>-J--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED</arg>
          <arg>-J--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED</arg>
          <arg>-J--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED</arg>
          <arg>-J--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED</arg>
          <arg>-J--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED</arg>
        </compilerArgs>


    </configuration>
  </plugin>

I don't think you can do it by modifying pom.xml only. The parameters are to be passed to the JVM that runs Maven itself.

Why couldn't you do it like this ?