编译spring-cloud-contract-2.2.1.RELEASE源码

鲲鹏镜像站中提供的二进制包是基于开源代码直接编译打包而成的,不含漏洞及BUG修复。

使用开源软件时需遵守开源软件的许可协议。

  1. 下载spring-cloud-contract-2.2.1.RELEASE源码。

    1
    2
    3
    cd /home
    git config --global http.sslVerify false
    git clone https://github.com/spring-cloud/spring-cloud-contract.git
    

  2. 切换到指定版本。

    1
    2
    cd spring-cloud-contract
    git checkout v2.2.1.RELEASE
    

  3. 替换wiremock-jre8-standalone-2.25.1.jar包。

    • 由于wiremock项目中依赖了conscrypt-openjdk-uber-2.1.0.jar,其中缺少适配Arm64架构的so文件引起了报错,需将本地Maven仓库中wiremock-jre8-standalone-2.25.1.jar替换。
    • wiremock-jre8-standalone-2.25.1.jar包可以通过华为鲲鹏镜像站直接下载获取,也可参考《wiremock-jre8-standalone-2.25.1.jar 移植指南》自行编译得到,本文使用直接从镜像站下载的方法。
    1. 创建库目录“~/.m2/repository/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/”
      1
      mkdir -p ~/.m2/repository/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/
      
    2. 获取wiremock-jre8-standalone-2.25.1.jar包。
      1
      wget https://mirrors.huaweicloud.com/kunpeng/maven/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/wiremock-jre8-standalone-2.25.1.jar  --no-check-certificate
      
    3. 将下载的JAR包复制到库目录下。
      1
      cp wiremock-jre8-standalone-2.25.1.jar ~/.m2/repository/com/github/tomakehurst/wiremock-jre8-standalone/2.25.1/
      

  4. 替换hoverfly-junit-0.2.2.jar包。

    • 编译过程中会拉取hoverfly-junit-0.2.2.jar,此Jar包中不含有Arm64架构的hoverfly二进制文件,需将本地Maven仓库中的hoverfly-junit-0.2.2.jar进行替换。
    • hoverfly-junit-0.2.2.jar包可以通过华为鲲鹏镜像站直接下载获取,也可参考《hoverfly-junit-0.2.2.jar移植指南》自行编译得到,本文使用直接从镜像站下载的方法。
    1. 创建库目录“~/.m2/repository/io/specto/hoverfly-junit/0.2.2/”
      1
      mkdir -p ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/
      
    2. 获取hoverfly-junit-0.2.2.jar包。
      1
      wget https://mirrors.huaweicloud.com/kunpeng/maven/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2.jar  --no-check-certificate
      
    3. 将下载的JAR包复制到库目录下。
      1
      cp hoverfly-junit-0.2.2.jar ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/
      
    4. 查看该JAR文件。
      jar tvf ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2.jar
    5. 将该JAR包解压到指定目录。
      unzip ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2.jar -d ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2
    6. 切换到解压后的目录,同时将hoverfly_v0.9.1_linux_arm64重命名为hoverfly_v0.9.1_linux_amd64。
      cd ~/.m2/repository/io/specto/hoverfly-junit/0.2.2/hoverfly-junit-0.2.2 && mv hoverfly_v0.9.1_linux_arm64 hoverfly_v0.9.1_linux_amd64
    7. 将当前目录中的所有文件打包为新的JAR包。
      jar cvf ../hoverfly-junit-0.2.2.jar -c ./*

  5. 执行编译。

    1
    2
    cd /home/spring-cloud-contract
    ./mvnw clean install -Dgpg.skip=true
    

    若显示BUILD SUCCESS,则编译通过。