How-to-build.md 4.5 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 7 8
## Build Project
**Because we are using Git submodule, we recommend don't use `GitHub` tag or release page to download source codes for compiling.**

### Build from GitHub
1. Prepare git, JDK8 and maven3
wu-sheng's avatar
wu-sheng 已提交
9
1. `git clone https://github.com/apache/incubator-skywalking.git`
10 11
1. `cd incubator-skywalking/`
1. Switch to the tag by using `git checkout [tagname]` (Optional, switch if want to build a release from source codes)
wu-sheng's avatar
wu-sheng 已提交
12 13
1. `git submodule init`
1. `git submodule update`
14
1. Run `./mvnw clean package -DskipTests`
wu-sheng's avatar
wu-sheng 已提交
15
1. All packages are in `/dist`.(.tar.gz for Linux and .zip for Windows).
16 17 18

### Build from Apache source codes
1. Prepare JDK8 and maven3
19
1. Run `./mvnw clean package -DskipTests`
wu-sheng's avatar
wu-sheng 已提交
20
1. All packages are in `/dist`.(.tar.gz for Linux and .zip for Windows).
wu-sheng's avatar
wu-sheng 已提交
21 22 23

## Setup your IntelliJ IDEA
1. Import the project as a maven project
24
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 已提交
25
1. Set **Generated Source Codes** folders.
26
    * `grpc-java` and `java` folders in **apm-protocol/apm-network/target/generated-sources/protobuf**
B
Bruce Wu 已提交
27
    * `grpc-java` and `java` folders in **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/generated-sources/protobuf**
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
    
## Setup your Eclipse IDE
1. Import the project as a maven project
2. For supporting multiple source directories, you need to add the following configuration in `incubator-skywalking/pom.xml` file:
```
<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>
```
3. Add the following configuration under to let eclipse's M2e plug-in supports execution's solution configuration
```
<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>
```
4. Adding Google guava dependency to apm-collector-remote/collector-remote-grpc-provider/pom.xml files
```
<dependency>
   <groupId>com.google.guava</groupId>
   <artifactId>guava</artifactId>
   <version>24.0-jre</version>
</dependency>
```
5. Run `./mvnw compile -Dmaven.test.skip=true`
6. Run `maven update`. Must remove the clean projects item before maven update(This will be clear the proto conversion Java file generated by the complie)
7. Run `./mvnw compile` complie collector-remote-grpc-provider and apm-protocol
8. Refresh project
97 98 99 100 101 102 103 104

## Building Resin-3, Resin-4, and OJDBC sdk plugins
Due to license incompatibilities/restrictions these plugins under `apm-sniffer/apm-sdk-plugin/` are not built by default.
Download them manually into the `ci-dependencies/` directory and the plugins will be included in the maven reactor and built.
The names of the artifacts downloaded and placed in the `ci-dependencies/` directory must be exact:
* resin-3.0.9.jar
* resin-4.0.41.jar
* ojdbc14-10.2.0.4.0.jar