Skip to content

Commit

Permalink
Add how to build in eclipse (#1464)
Browse files Browse the repository at this point in the history
* Update How-to-build-CN.md
  • Loading branch information
Xlinlin authored and wu-sheng committed Jul 18, 2018
1 parent 630e623 commit 06b6f05
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 0 deletions.
75 changes: 75 additions & 0 deletions docs/cn/How-to-build-CN.md
Expand Up @@ -28,6 +28,81 @@
1. 设置gRPC的自动生成代码目录,为源码目录
- **apm-protocol/apm-network/target/generated-sources/protobuf**目录下的`grpc-java``java`目录
- **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/generated-sources/protobuf**目录下的`grpc-java``java`目录

## 在IntelliJ IDEA中编译工程
上述步骤在命令行中,能够很好的编译工程,但导入到编译器中的工程依然会有一些报错,我们需要进行几步简单的操作。
1. 在IntelliJ Terminal中,执行`mvn compile -Dmaven.test.skip=true`进行编译
1. 设置gRPC的自动生成代码目录,为源码目录
- **apm-protocol/apm-network/target/generated-sources/protobuf**目录下的`grpc-java``java`目录
- **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/generated-sources/protobuf**目录下的`grpc-java``java`目录

## 在Eclipse IDE中编译工程
1. 导入incubator-skywalking maven工程
2. 在主目录incubator-skywalking/pom.xml文件中添加如下两个plugin配置,首先配置多源码目录支持,在build/plugins节点下添加如下配置:
```
<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>
```
其次需要支持多source目录,但eclipse的m2e插件还没支持到execution,需要在在build节点下添加如下配置:
```
<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>
```
3. 修改apm-collector-remote/collector-remote-grpc-provider/pom.xml文件,添加google guava的依赖
```
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>24.0-jre</version>
</dependency>
```
4. 执行`mvn compile -Dmaven.test.skip=true`进行编译
5. 执行maven update,切记去掉勾选 Clean projects选项(会清掉complie生成的proto转化Java文件)
6. mvn compile 编译collector-remote-grpc-provider和apm-protocol工程并Refresh

## 编译Resin-3, Resin-4 和 Oracle JDBC 驱动插件
为了遵守Apache关于协议(License)的相关要求,不符合Apache相关要求的类库所对应的Plugin不会自动编译。如需编译对应的插件,
Expand Down
69 changes: 69 additions & 0 deletions docs/en/How-to-build.md
Expand Up @@ -25,6 +25,75 @@ This document helps people to compile and build the project in your maven and se
1. 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 **apm-collector/apm-collector-remote/apm-remote-grpc-provider/target/generated-sources/protobuf**

## 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 `mvn 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 `mvn compile` complie collector-remote-grpc-provider and apm-protocol
8. Refresh project

## 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.
Expand Down

2 comments on commit 06b6f05

@ni-ze
Copy link

@ni-ze ni-ze commented on 06b6f05 Jul 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我就想问问:有几个按照这份说明在idea把项目编译通过的?"1. 设置gRPC的自动生成代码目录,为源码目录"这一步apm-network包下的proto文件夹下根本就没有.proto文件,编译maven怎么会有源代码出现?逗我?

@wu-sheng
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to read build document. You miss the important parts.

Please sign in to comment.