Skip to content

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

@BilgehanYildiz

Description

@BilgehanYildiz

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions