Mac M 系列芯片编译 protoc 报错

60次阅读
没有评论

共计 2082 个字符,预计需要花费 6 分钟才能阅读完成。

现象

执行 mvn clean package -DskipTestsORC 打包失败,报错如下:

[INFO] Resolving artifact: com.google.protobuf:protoc:2.5.0, platform: osx-aarch_64
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache ORC 1.5.8:
[INFO]
[INFO] Apache ORC ......................................... SUCCESS [  0.844 s]
[INFO] ORC Shims .......................................... SUCCESS [  1.040 s]
[INFO] ORC Core ........................................... FAILURE [  0.046 s]
[INFO] ORC MapReduce ...................................... SKIPPED
[INFO] ORC Tools .......................................... SKIPPED
[INFO] ORC Examples ....................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.003 s
[INFO] Finished at: 2022-02-23T14:59:43+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.os72:protoc-jar-maven-plugin:3.5.1.1:run (default) on project orc-core: Error resolving artifact: com.google.protobuf:protoc:2.5.0: Could not transfer artifact com.google.protobuf:protoc:exe:osx-aarch_64:2.5.0 from/to maven-default-http-blocker XXXXX
[ERROR]   com.google.protobuf:protoc:exe:2.5.0
[ERROR]
[ERROR] from the specified remote repositories:
[ERROR]  XXX
[ERROR] -> [Help 1]
[ERROR]

分析

从报错即可看出,打包时由于系统为 osx-aarch_64 架构,所以会去找 protoc-2.5.0-osx-aarch_64 名字样式的包,查看 nexus 仓库,没有这种名字的包:
Mac M 系列芯片编译 protoc 报错

修改思路当然是将 protoc-2.5.0-osx-aarch_64.exe 替换为 protoc-2.5.0-osx-x86_64.exe。查看文档知系统架构通过 os.arch 指定即可,于是执行 mvn clean package -DskipTests -Dos.arch=x86_64,打包成功。

查了下网络上的解决方案,若 pom.xml 文件中使用的插件能设置 protoc 的 os arch 类型,也可以直接修改该 os arch,或修改 ./m2/settings.xml 文件:

<settings>
  ...
  <activeProfiles>
    <activeProfile>
      apple-silicon
    </activeProfile>
    ...
  </activeProfiles>
  <profiles>
    <profile>
      <id>apple-silicon</id>
      <properties>
        <os.detected.classifier>osx-x86_64</os.detected.classifier>
      </properties>
    </profile>
    ...
  </profiles>
  ...
</settings>

解决方案

如果使用的插件不支持设置 protoc 的 os arch,如笔者遇到的 ORC,尝试执行 mvn clean package -DskipTests -Dos.arch=x86_64;若插件支持设置 protoc 的 os arch,则可在 pom.xml 中直接指定,或修改 settings.xml 文件,指定 os arch。

正文完
 0
管理员
版权声明:本站原创文章,由 管理员 于2022-02-23发表,共计2082字。
转载说明:除特殊说明外本站文章皆由 CC-4.0 协议发布,转载请注明出处。
评论(没有评论)