簡體   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

我有一個子項目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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM