首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Maven构建失败:在执行com.cosium.code:git-code-格式-maven-plugin时遇到了一个API不兼容性

Maven构建失败:在执行com.cosium.code:git-code-格式-maven-plugin时遇到了一个API不兼容性
EN

Stack Overflow用户
提问于 2022-08-04 08:59:32
回答 1查看 606关注 0票数 0

我有一个子项目Project C,它依赖于Maven的物料清单(BOM)父项目Project P。父项目Project P包含一些需要应用于所有子项目的代码样式和格式。

我没有将这些代码样式应用于我的子项目Project C,因为当我在子项目Project C上运行mvn clean install时,会得到以下错误:

代码语言:javascript
运行
复制
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

引用的全部错误:

代码语言:javascript
运行
复制
[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中的校验样式选项,并希望构建该项目。如何做到这一点?我尝试了这里提到的一些答案,比如:https://stackoverflow.com/a/70023748/7584240,但是它似乎对我没有用,并且得到了相同的错误。请就这个问题提出一些建议.

如果我删除插件:使用groupId、com.cosium.code和工件ID:git-code-format-maven-plugin,但是我不希望对父项目做任何更改,而是处理子项目中的所有内容。

**更新:**

在基于文档进行了一些更改之后,我只获得了一个特定文件的错误。我不知道为什么会出现这个错误,因为它应该跳过所有文件的格式检查。我试图按照intellij格式格式化该文件,但仍然无法构建。

我按照文档将以下内容添加到我的pom.xml中:

代码语言:javascript
运行
复制
<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> 
EN

回答 1

Stack Overflow用户

发布于 2022-08-04 12:20:23

您可以跳过在子项目中执行插件,通过绑定插件到阶段none,例如:

代码语言:javascript
运行
复制
<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> 

您还可以通过不继承子模块的配置,在一个指定的模块中执行此操作:

代码语言:javascript
运行
复制
<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> 
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73233068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档