How-to-build.md 6.8 KB
Newer Older
wu-sheng's avatar
wu-sheng 已提交
1
# How to build project
2
This document helps people to compile and build the project in your maven and set your IDE.
wu-sheng's avatar
wu-sheng 已提交
3

4 5 6
## Build Project
**Because we are using Git submodule, we recommend don't use `GitHub` tag or release page to download source codes for compiling.**

J
José Augusto 已提交
7 8
### Maven behind Proxy
If you need to execute build behind the proxy, edit the *.mvn/jvm.config* and put the follow properties:
9
```properties
J
José Augusto 已提交
10 11 12 13 14 15 16 17
-Dhttp.proxyHost=proxy_ip
-Dhttp.proxyPort=proxy_port
-Dhttps.proxyHost=proxy_ip
-Dhttps.proxyPort=proxy_port 
-Dhttp.proxyUser=username
-Dhttp.proxyPassword=password
```

18 19
### Build from GitHub
1. Prepare git, JDK8 and maven3
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
1. 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.
    
    ```bash
    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
    ```
   
36
1. Run `./mvnw clean package -DskipTests`
37
1. All packages are in `/dist` (.tar.gz for Linux and .zip for Windows).
38

wu-sheng's avatar
wu-sheng 已提交
39 40 41 42 43
### Build from Apache source code release
- What is `Apache source code release`?

For each official Apache release, there is a complete and independent source code tar, which is including all source codes. You could download it from [SkyWalking Apache download page](http://skywalking.apache.org/downloads/). No git related stuff required when compiling this. Just follow these steps.

44
1. Prepare JDK8 and maven3
45
1. Run `./mvnw clean package -DskipTests`
wu-sheng's avatar
wu-sheng 已提交
46
1. All packages are in `/dist`.(.tar.gz for Linux and .zip for Windows).
wu-sheng's avatar
wu-sheng 已提交
47

48 49 50 51 52
### Advanced compile
SkyWalking is a complex maven project, including many modules, which could cause long compiling time. 
If you just want to recompile part of the project, you have following options
- Compile agent and package
>  ./mvnw package -Pagent,dist
53 54 55 56 57

or

> make build.agent

58 59
- Compile backend and package
>  ./mvnw package -Pbackend,dist
60 61 62 63 64

or

> make build.backend

65 66 67
- Compile UI and package
>  ./mvnw package -Pui,dist

68 69 70 71 72 73 74 75
or

> make build.ui


### Build docker images
We can build docker images of `backend` and `ui` with `Makefile` located in root folder.

G
Gao Hongtao 已提交
76
Refer to [Build docker image](../../../docker) for more details.
77

wu-sheng's avatar
wu-sheng 已提交
78
## Setup your IntelliJ IDEA
D
Daming 已提交
79 80
**NOTICE**: If you clone the codes from GitHub, please make sure that you had finished step 1 to 7 in section **[Build from GitHub](#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](#build-from-apache-source-code-release)**.

wu-sheng's avatar
wu-sheng 已提交
81
1. Import the project as a maven project
82
1. Run `./mvnw compile -Dmaven.test.skip=true` to compile project and generate source codes. Because we use gRPC and protobuf.
wu-sheng's avatar
wu-sheng 已提交
83
1. Set **Generated Source Codes** folders.
84
    * `grpc-java` and `java` folders in **apm-protocol/apm-network/target/generated-sources/protobuf**
X
XiaoFu 已提交
85
    * `grpc-java` and `java` folders in **oap-server/server-core/target/generated-sources/protobuf**
wu-sheng's avatar
wu-sheng 已提交
86
    * `grpc-java` and `java` folders in **oap-server/server-receiver-plugin/receiver-proto/target/generated-sources/protobuf**
wu-sheng's avatar
wu-sheng 已提交
87
    * `grpc-java` and `java` folders in **oap-server/exporter/target/generated-sources/protobuf**
88
    * `grpc-java` and `java` folders in **oap-server/server-configuration/grpc-configuration-sync/target/generated-sources/protobuf**
W
wuguangkuo 已提交
89
    * `antlr4` folder in **oap-server/oal-grammar/target/generated-sources**
90 91
    
## Setup your Eclipse IDE
D
Daming 已提交
92 93
**NOTICE**: If you clone the codes from GitHub, please make sure that you had finished step 1 to 7 in section **[Build from GitHub](#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](#build-from-apache-source-code-release)**.

94
1. Import the project as a maven project
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
1. For supporting multiple source directories, you need to add the following configuration in `skywalking/pom.xml` file:
    ```xml
    <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.8</version>
        <executions>
            <execution>
                <id>add-source</id>
                <phase>generate-sources</phase>
                <goals>
                    <goal>add-source</goal>
                </goals>
                <configuration>
                    <sources>
                        <source>src/java/main</source>
                        <source>apm-protocol/apm-network/target/generated-sources/protobuf</source>
                        <source>apm-collector/apm-collector-remote/collector-remote-grpc-provider/target/generated-sources/protobuf</source>
                   </sources>
                </configuration>
            </execution>
        </executions>
    </plugin>
    ```
1. Add the following configuration under to let eclipse's M2e plug-in supports execution's solution configuration
    ```xml
    <pluginManagement>
        <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings 
        only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>build-helper-maven-plugin</artifactId>
                                    <versionRange>[1.8,)</versionRange>
                                    <goals>
                                        <goal>add-source</goal>
                                    </goals>
                                </pluginExecutionFilter>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
    ```
1. Adding Google guava dependency to apm-collector-remote/collector-remote-grpc-provider/pom.xml files
    ```xml
    <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
       <version>24.0-jre</version>
    </dependency>
    ```
1. Run `./mvnw compile -Dmaven.test.skip=true`
1. Run `maven update`. Must remove the clean projects item before maven update(This will be clear the proto conversion Java file generated by the compiling)
1. Run `./mvnw compile` compile collector-remote-grpc-provider and apm-protocol
1. Refresh project