我要评分
获取效率
正确性
完整性
易理解

Compiling the spring-cloud-gcp-1.2.1.RELEASE Source Code

The binary packages available at the Kunpeng mirror site are compiled and packaged based on the open source code, and do not involve vulnerability or bug fixes.

When using open source software, comply with the applicable license.

  1. Download the spring-cloud-gcp-1.2.1.RELEASE source package.
    1
    2
    3
    cd /home
    git config --global http.sslVerify false
    git clone https://github.com/spring-cloud/spring-cloud-gcp.git
    
  2. Switch to the target version.
    1
    2
    cd spring-cloud-gcp
    git checkout v1.2.1.RELEASE
    
  3. Configure the google-cloud-sdk Yum source. (If the current environment does not require a proxy to access the network, skip this step.)
    1. Back up the Yum source.
      mkdir -p /etc/yum.repos.d/bak/
      mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bak/
    2. Create the google-cloud-sdk.repo file.
      1
      vim /etc/yum.repos.d/google-cloud-sdk.repo
      
    3. Press i to enter the insert mode and add the following content to the file:
      [google-cloud-sdk] 
      name=Google Cloud SDK 
      baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el7-x86_64 
      enabled=1 
      gpgcheck=0 
      repo_gpgcheck=1 
      gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
      sslverify=false
    4. Press Esc, type :wq!, and press Enter to save the file and exit.
    5. Make the Yum source take effect.
      1
      2
      yum clean all
      yum makecache
      
  4. Install google-cloud-sdk, google-cloud-sdk-pubsub-emulator, and google-cloud-sdk-datastore-emulator. (If the current environment does not require a proxy to access the network, skip this step.)
    1
    yum install -y google-cloud-sdk google-cloud-sdk-pubsub-emulator google-cloud-sdk-datastore-emulator
    

    If the error message "(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)" is reported during the compilation, run the following command:

    yum install -y google-cloud-sdk google-cloud-sdk-pubsub-emulator google-cloud-sdk-datastore-emulator --nobest
  5. Complete the initialization. (If the current environment does not require a proxy to access the network, skip this step.)
    1
    gcloud init
    
    • When you run the gcloud command to initialize the environment, you need to log in to your Google account. Register a Google account if you do not have one.
    • If the compilation environment needs to use proxy to access the Google website, copy the link to the browser, and enter the verification code to perform initialization, as shown in the following figure.

      If "Enter project id you would like to use" is displayed, enter spring-cloud-gcp.

    • If you have logged in using a Google account, select the Google account.
  6. Start datastore and pubsub. (If the current environment does not require a proxy to access the network, skip this step.)
    1
    2
    gcloud beta emulators datastore start --host-port localhost:8181 &
    gcloud beta emulators pubsub start --host-port localhost:8085 &
    
  7. Replace the JAR package.

    During the compilation, the grpc-netty-shaded-1.23.0.jar package is pulled. This JAR package does not contain SO files of the ARM64 architecture and you need to replace the JAR package.

    1. Create the library directory ~/.m2/repository/io/grpc/grpc-netty-shaded/1.23.0/.
      1
      mkdir -p ~/.m2/repository/io/grpc/grpc-netty-shaded/1.23.0/
      
    2. Obtain the grpc-netty-shaded-1.23.0.jar package.
      1
      wget https://mirrors.huaweicloud.com/kunpeng/maven/io/grpc/grpc-netty-shaded/1.23.0/grpc-netty-shaded-1.23.0.jar  --no-check-certificate
      
    3. Copy the downloaded JAR package to the library directory.
      1
      cp grpc-netty-shaded-1.23.0.jar ~/.m2/repository/io/grpc/grpc-netty-shaded/1.23.0/
      
  8. Perform the compilation.
    1
    ./mvnw clean install -Dgpg.skip=true
    

    If BUILD SUCCESS is displayed, the compilation is successful.

    • If the error message "GcpDatastoreEmulatorIntegrationTests" is reported during the compilation, rectify the fault by following instructions in spring-cloud-gcp Error.
    • Read and write capabilities of old HDDs are weak. As a result, the service processing latency is long. You are advised to use drives with better performance, such as SSDs, for service verification.
    • If the compilation process is suspended, you are advised to restart the server, mount the drive to the compilation directory, and then perform 6 (optional) and 8.
  9. After the compilation is complete, disable the datastore and pubsub services.
    1
    pkill -9 java