![](/img/trans.png)
[英]nexus-staging-maven-plugin: maven deploy failed: An API incompatibility was encountered while executing
[英]Maven build fails with error: An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin
我有一个子项目Project C
,它依赖于 Maven 的物料清单 (BOM) 父项目Project P
。 父项目Project P
包含一些代码 styles 和需要应用于所有子项目的格式。
我没有将这些代码 styles 应用到我的子项目Project C
因为当我在子项目Project C
上运行mvn clean install
时,我得到错误:
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
参考的完整错误:
[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
我想关闭 maven 中的 checkstyle 选项并想构建项目。 如何做到这一点? 我尝试了这里提到的一些答案,例如: https://stackoverflow.com/a/70023748/7584240但它似乎对我根本不起作用并且得到相同的错误。 请为此问题提出一些解决方法。
如果我删除插件:使用 groupId com.cosium.code
和工件 ID: git-code-format-maven-plugin
但我不希望对父项目进行任何更改,而是处理子项目中的所有内容。
**更新: **
根据文档进行一些更改后,我只收到一个特定文件的错误。 我不确定为什么会出现该错误,因为它应该跳过检查所有文件的格式。 我尝试按照 intellij 格式格式化该文件,但仍然构建失败。
根据文档,我在 pom.xml 中添加了以下内容:
<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>
您可以在子项目中完全跳过执行插件,通过将插件绑定到阶段none
,例如:
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.