天天看點

【小筆記】idea裡面編譯與調試Skywalking源碼一、編譯二、調試

一、編譯

文檔:https://github.com/apache/skywalking/blob/master/docs/en/guides/How-to-build.md#build-from-github

搬運:

Build from GitHub

  1. Prepare git, JDK8+ and Maven 3.6+
  2. Clone project

    If you want to build a release from source codes, provide a 

    tag name

     by using 

    git clone -b [tag_name] ...

     while cloning.
    git clone --recurse-submodules https://github.com/apache/skywalking.git
    cd skywalking/
    
    OR
    
    git clone https://github.com/apache/skywalking.git
    cd skywalking/
    git submodule init
    git submodule update      
  3. Run 

    ./mvnw clean package -DskipTests

  4. All packages are in 

    /dist

     (.tar.gz for Linux and .zip for Windows).

NOTICE: If you clone the codes from GitHub, please make sure that you had finished step 1 to 3 in section Build from GitHub, if you download the source codes from the official website of SkyWalking, please make sure that you had followed the steps in section Build from Apache source code release.

  1. Import the project as a maven project
  2. Run 

    ./mvnw compile -Dmaven.test.skip=true

     to compile project and generate source codes. Because we use gRPC and protobuf.
  3. Set Generated Source Codes folders.
    • grpc-java

       and 

      java

       folders in apm-protocol/apm-network/target/generated-sources/protobuf
    • grpc-java

       and 

      java

       folders in oap-server/server-core/target/generated-sources/protobuf
    • grpc-java

       and 

      java

       folders in oap-server/server-receiver-plugin/receiver-proto/target/generated-sources/protobuf
    • grpc-java

       and 

      java

       folders in oap-server/exporter/target/generated-sources/protobuf
    • grpc-java

       and 

      java

       folders in oap-server/server-configuration/grpc-configuration-sync/target/generated-sources/protobuf
    • antlr4

       folder in oap-server/oal-grammar/target/generated-sources

注意:由于Skywalking用到的lombok,是以idea必須要裝這個插件

二、調試

與調試chaosblade代碼類似:

好處:

  • 打斷點分析問題
  • 修改代碼不用編譯,實時生效

效果圖

【小筆記】idea裡面編譯與調試Skywalking源碼一、編譯二、調試

(調試skywalking采樣算法)

遠端java程式需要配置一下jvm參數

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

IDEA配置

【小筆記】idea裡面編譯與調試Skywalking源碼一、編譯二、調試