简体   繁体   English

Maven 构建失败并出现错误:执行 com.cosium.code:git-code-format-maven-plugin 时遇到 API 不兼容

[英]Maven build fails with error: An API incompatibility was encountered while executing com.cosium.code:git-code-format-maven-plugin

I have a child project Project C which has a dependency on the Maven's Bill of Materials (BOM) parent project Project P .我有一个子项目Project C ,它依赖于 Maven 的物料清单 (BOM) 父项目Project P The parent project Project P contains some of the code styles and formatting which needs to be applied to all the child project.父项目Project P包含一些代码 styles 和需要应用于所有子项目的格式。

I do not which to apply these code styles to my child project Project C due to which when I run the mvn clean install on the child project Project C , I get the error:我没有将这些代码 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

Full error for the 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.我想关闭 maven 中的 checkstyle 选项并想构建项目。 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.我尝试了这里提到的一些答案,例如: https://stackoverflow.com/a/70023748/7584240但它似乎对我根本不起作用并且得到相同的错误。 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 change to parent project rather handle everything in child project.如果我删除插件:使用 groupId com.cosium.code和工件 ID: git-code-format-maven-plugin但我不希望对父项目进行任何更改,而是处理子项目中的所有内容。

**Updated: ** **更新: **

After making some changes based on the documentation , I am getting the error for only one particular file.根据文档进行一些更改后,我只收到一个特定文件的错误。 I am not sure why am I getting that error because it should skip the checking of the formatting for all the file.我不确定为什么会出现该错误,因为它应该跳过检查所有文件的格式。 I tried to format that file as per intellij formatting but still build is failing.我尝试按照 intellij 格式格式化该文件,但仍然构建失败。

I have added following to my pom.xml as per documentation:根据文档,我在 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> 

You can skip executing plugin at all in child project, by bind plugin to phase none , eg:您可以在子项目中完全跳过执行插件,通过将插件绑定到阶段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.

相关问题 nexus-staging-maven-plugin:maven 部署失败:执行时遇到 API 不兼容 - nexus-staging-maven-plugin: maven deploy failed: An API incompatibility was encountered while executing maven-release-plugin:2.5.1:perform failed: 执行时遇到 API 不兼容 - maven-release-plugin:2.5.1:perform failed: An API incompatibility was encountered while executing maven-help-plugin:2.1.1:effective-settings failed: 执行时遇到 API 不兼容 - maven-help-plugin:2.1.1:effective-settings failed: An API incompatibility was encountered while executing org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar 失败:执行时遇到 API 不兼容问题 - org.sonarsource.scanner.maven:sonar-maven-plugin:3.8.0.2131:sonar failed: An API incompatibility was encountered while executing 执行 org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade: java.lang.AbstractMethodError: null 时遇到 API 不兼容 - An API incompatibility was encountered while executing org.apache.maven.plugins:maven-shade-plugin:1.3.1:shade: java.lang.AbstractMethodError: null JavaFX maven插件和API不兼容 - JavaFX maven plugin and API incompatibility Maven CXF插件API不兼容 - Maven CXF plugin API incompatibility GMaven 构建失败并显示“遇到 API 不兼容” - GMaven build fails with "An API incompatibility was encountered" 运行构建 maven 项目时出错 - 插件,API 不兼容 - Error while running building maven project - plugins, API incompatibility 由于 API 不兼容,无法构建 Maven - Fail to Maven Build due to an API incompatibility
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM