Reputation: 3530
I have a child project, Project C
, which has a dependency on the Maven's Bill of Materials (BOM) parent project, Project P
. The parent project, Project P
, contains some of the code styles and formatting which need to be applied to all the child projects.
I do not know how to apply these code styles to my child project, Project C
, due to, when I run the mvn clean install
on the child project, I get the error:
An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin:3.4:validate-code-format: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x56da96b3) cannot access class com.sun.tools.javac.parser.Tokens$TokenKind
Full error for reference:
[ERROR] Failed to execute goal com.cosium.code:git-code-format-maven-plugin:3.4:validate-code-format (validate-code-format) on project project-c: Execution validate-code-format of goal com.cosium.code:git-code-format-maven-plugin:3.4:validate-code-format failed: An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin:3.4:validate-code-format: java.lang.IllegalAccessError: class com.google.googlejavaformat.java.JavaInput (in unnamed module @0x4a320414) 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 @0x4a320414
I would like to turn off the checkstyle option in maven and would like to build the project. How to achieve this? I tried some of the answers mentioned here such as: https://stackoverflow.com/a/70023748/7584240 but it does not seem to work for me at all and getting the same error. Please suggest some work-arounds to this issue.
If I remove the plugin: with groupId com.cosium.code
and artifact ID: git-code-format-maven-plugin
but I do not wish to make any changes to the parent project but instead handle everything in the child project.
After making some changes based on the documentation, I am getting the error for only one particular file. I am not sure why I am getting that error because it should skip the checking of the formatting for all the files. I tried to format that file as per intellij formatting but still build is failing.
I have added the following to my pom.xml
as per documentation:
<plugin>
<groupId>com.cosium.code</groupId>
<artifactId>git-code-format-maven-plugin</artifactId>
<version>${git-code-format-maven-plugin.version}</version>
<configuration>
<skip>true</skip>
<googleJavaFormatOptions>
<aosp>false</aosp>
</googleJavaFormatOptions>
</configuration>
</plugin>
Upvotes: 0
Views: 6331
Reputation: 8547
You can skip executing plugin at all in child project, by bind plugin to phase none
, eg:
<plugin>
<groupId>com.cosium.code</groupId>
<artifactId>git-code-format-maven-plugin</artifactId>
<executions>
<execution>
<id>validate-code-format</id><!-- the same as in parent -->
<phase>none</phase>
</execution>
</executions>
</plugin>
You can also do it in one specified module by not inherited configuration to child module:
<plugin>
<groupId>com.cosium.code</groupId>
<artifactId>git-code-format-maven-plugin</artifactId>
<executions>
<execution>
<inherited>false</inherited>
<id>validate-code-format</id><!-- the same as in parent -->
<phase>none</phase>
</execution>
</executions>
</plugin>
Upvotes: 0