This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 6a7583b  [Doc] Add doc for setting dev env of FE in Eclipse (#3952)
6a7583b is described below

commit 6a7583bb0802f39cc16c8e656e5daf1ded8f0d01
Author: Mingyu Chen <morningman....@gmail.com>
AuthorDate: Thu Jul 2 13:54:36 2020 +0800

    [Doc] Add doc for setting dev env of FE in Eclipse (#3952)
    
    Also fix some doc bugs
---
 .../public/images/eclipse-import-fe-project-1.png  | Bin 0 -> 69072 bytes
 docs/.vuepress/sidebar/en.js                       |   6 +-
 docs/.vuepress/sidebar/zh-CN.js                    |   7 +-
 docs/en/developer-guide/fe-eclipse-dev.md          | 164 +++++++++++++++++++++
 docs/zh-CN/developer-guide/fe-eclipse-dev.md       | 164 +++++++++++++++++++++
 docs/zh-CN/developer-guide/fe-idea-dev.md          |  14 +-
 6 files changed, 346 insertions(+), 9 deletions(-)

diff --git a/docs/.vuepress/public/images/eclipse-import-fe-project-1.png 
b/docs/.vuepress/public/images/eclipse-import-fe-project-1.png
new file mode 100644
index 0000000..e33d9f3
Binary files /dev/null and 
b/docs/.vuepress/public/images/eclipse-import-fe-project-1.png differ
diff --git a/docs/.vuepress/sidebar/en.js b/docs/.vuepress/sidebar/en.js
index 17140e0..d47c96e 100644
--- a/docs/.vuepress/sidebar/en.js
+++ b/docs/.vuepress/sidebar/en.js
@@ -461,7 +461,11 @@ module.exports = [
   {
     title: "Developer Guide",
     directoryPath: "developer-guide/",
-    children: ["debug-tool", "format-code"],
+    children: [
+        "debug-tool",
+        "format-code",
+        "fe-eclipse-dev"
+    ],
   },
   {
     title: "Apache Community",
diff --git a/docs/.vuepress/sidebar/zh-CN.js b/docs/.vuepress/sidebar/zh-CN.js
index 7639786..606f6c9 100644
--- a/docs/.vuepress/sidebar/zh-CN.js
+++ b/docs/.vuepress/sidebar/zh-CN.js
@@ -474,7 +474,12 @@ module.exports = [
   {
     title: "开发者手册",
     directoryPath: "developer-guide/",
-    children: ["debug-tool", "format-code","fe-idea-dev"],
+    children: [
+        "debug-tool",
+        "format-code",
+        "fe-idea-dev",
+        "fe-eclipse-dev"
+    ],
   },
   {
     title: "Apache 社区",
diff --git a/docs/en/developer-guide/fe-eclipse-dev.md 
b/docs/en/developer-guide/fe-eclipse-dev.md
new file mode 100644
index 0000000..c4834be
--- /dev/null
+++ b/docs/en/developer-guide/fe-eclipse-dev.md
@@ -0,0 +1,164 @@
+---
+{
+    "title": "Setting FE dev env - Eclipse",
+    "language": "en"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# Setting FE dev env using Eclipse
+
+## Preparation
+
+* JDK 1.8+
+* Maven 3.x+
+* Eclipse,with [M2Eclipse](http://www.eclipse.org/m2e/) installed
+
+### Code Generation
+
+The FE module requires part of the generated code, such as Thrift, Protobuf 
and other frameworks. This part needs to be generated by compiling the contents 
of the `gensrc/` directory in the Linux environment.
+
+1. Under Linux, enter the source code directory and execute the following 
command:
+
+    ```
+    sh build.sh --clean --fe
+    ```
+    
+2. Then package the generated `gensrc/build/java` directory:
+
+    `cd gensrc/build/ && tar czf java.tar.gz java/`
+
+3. Copy `java.tar.gz` to the `fe/` directory of the development environment 
and unzip
+
+    ```
+    cp java.tar.gz /path/to/doris/fe/
+    cd /path/to/doris/fe/ && tar xzf java.tar.gz
+    ```
+
+## Import FE project
+
+1. In the `fe/` directory of the development environment, execute the 
following command to generate the Eclipse project file:
+
+    `cd /path/to/doris/fe/ && mvn -npr eclipse:eclipse -Dskip.plugin=true`
+    
+    After the execution is completed, the `.project` and `.classpath` files 
will be generated in the `fe/` directory.
+
+2. Import FE project
+
+    * Open Eclipse,choose `File -> Import`.
+    * Choose `General -> Existing Projects into Workspace`.
+    * `Select root directory` and choose `fe/` directory,click `Finish` to 
finish.
+    * Right click the project, and choose `Build Path -> Configure Build Path`.
+    * In the `Java Build Path` dialog, choose the `Source` tab, click `Add 
Folder`, and select the `java/` directory that was copied and unzipped before 
adding.
+    * Click `Apply and Close` to finish.
+
+At this point, FE project import is complete. The project directory in Eclipse 
is roughly as follows:
+
+![](/images/eclipse-import-fe-project-1.png)
+
+## Run Unit Test
+
+Right-click on the unit test file you want to run and select `Run As -> JUnit 
Test`. (If you want to debug, select `Debug As -> JUnit Test`).
+
+If the following error occurs:
+
+```
+java.lang.Exception: Method xxxx should have no parameters
+```
+
+Then right-click the unit test file and select `Run As -> Run 
Configurations...`. (If you want to debug, select `Debug As -> Debug 
Configurations...`).
+
+Add to the `VM arguments` in the `Arguments` tab:
+
+```
+-javaagent:${settings.localRepository}/org/jmockit/jmockit/1.48/jmockit-1.48.jar
+```
+
+Among them, `${settings.localRepository}` should be replaced with the path of 
the maven library path, such as:
+
+```
+-javaagent:/Users/cmy/.m2/repository/org/jmockit/jmockit/1.48/jmockit-1.48.jar
+```
+
+Then just run `Run/Debug`.
+
+## Run FE
+
+You can directly start an FE process in Ecplise to facilitate debugging the 
code.
+
+1. Create a runtime directory
+
+    ```
+    mkdir /path/to/doris/fe/run/
+    cd /path/to/doris/fe/run/
+    mkdir conf/ log/ palo-meta/
+    ```
+    
+2. Create configuration file
+    
+    Create the configuration file `fe.conf` in the `conf/` directory created 
in the first step. You can directly copy `conf/fe.conf` in the source directory 
and make simple changes.
+    
+3. Find the `src/main/java/org/apache/doris/PaloFe.java` file in Ecplise, 
right-click and select `Run As -> Run Configurations...`. Add the following 
environment variables to the `Environment` tab:
+
+    * `DORIS_HOME: /path/to/doris/fe/run/`
+    * `PID_DIR: /path/to/doris/fe/run/`
+    * `LOG_DIR: /path/to/doris/fe/run/log`
+
+4. Right-click `PaloFe.java` and select `Run As -> Java Application` to start 
FE.
+
+## Code Update
+
+1. Update lexical and grammar files
+
+    If you modified `fe/src/main/cup/sql_parser.cup` or 
`fe/src/main/jflex/sql_scanner.flex` file. You need to execute the following 
commands in the `fe/` directory:
+    
+    ```
+    mvn de.jflex:maven-jflex-plugin:1.4.3:generate
+    mvn net.sourceforge.czt.dev:cup-maven-plugin:1.6-cdh:generate
+    ```
+    
+    Then refresh the project in Eclipse.
+        
+2. Update maven dependencies
+
+    If you update the dependency in `fe/pom.xml`, you need to execute the 
following command in the `fe/` directory:
+
+    `mvn -npr eclipse:eclipse -Dskip.plugin=true`
+    
+    Then refresh the project in Eclipse. If it cannot be updated, it is 
recommended to delete the project and import it again according to this 
document.
+
+## Imports Order
+
+In order to maintain the Imports order of Java, please perform the following 
operations to set the Imports Order of the project.
+
+1. Create the file `fe_doris.importorder` and write the following:
+
+    ```
+    #Organize Import Order
+    #Wed Jul 01 16:42:47 CST 2020
+    4=javax
+    3=java
+    2=org
+    1=com
+    0=org.apache.doris
+    ```
+
+2. Open Eclipse Preferences, select `Java -> Code Style -> Organize Imports`. 
Click `Import` to import the above file.
diff --git a/docs/zh-CN/developer-guide/fe-eclipse-dev.md 
b/docs/zh-CN/developer-guide/fe-eclipse-dev.md
new file mode 100644
index 0000000..25c0132
--- /dev/null
+++ b/docs/zh-CN/developer-guide/fe-eclipse-dev.md
@@ -0,0 +1,164 @@
+---
+{
+    "title": "FE 开发环境搭建 - Eclipse",
+    "language": "zh-CN"
+}
+---
+
+<!-- 
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+
+# 使用 Eclipse 搭建 FE 开发环境
+
+## 环境准备
+
+* JDK 1.8+
+* Maven 3.x+
+* Eclipse,并已安装 [M2Eclipse](http://www.eclipse.org/m2e/)
+
+### 代码生成
+
+FE 模块需要部分生成代码,如 Thrift、Protobuf 等框架的生成代码。这部分需要在 Linux 环境中通过编译 `gensrc/` 
目录中的内容生成。
+
+1. 在 Linux 下,进入到源码目录,执行下面的命令:
+
+    ```
+    sh build.sh --clean --fe
+    ```
+    
+2. 然后将生成的 `gensrc/build/java` 目录打包:
+
+    `cd gensrc/build/ && tar czf java.tar.gz java/`
+
+3. 将 `java.tar.gz` 拷贝到开发环境的 `fe/` 目录下,并解压
+
+    ```
+    cp java.tar.gz /path/to/doris/fe/
+    cd /path/to/doris/fe/ && tar xzf java.tar.gz
+    ```
+
+## 导入 FE 工程
+
+1. 在开发环境的 `fe/` 目录下,执行以下命令生成 Eclipse 工程文件:
+
+    `cd /path/to/doris/fe/ && mvn -npr eclipse:eclipse -Dskip.plugin=true`
+    
+    执行完成后,会在 `fe/` 目录下生成 `.project` 和 `.classpath` 文件
+
+2. 导入 FE 工程
+
+    * 打开 Eclipse,选择 `File -> Import`。
+    * 选择 `General -> Existing Projects into Workspace`。
+    * `Select root directory` 选择 `fe/` 目录,点击 `Finish` 完成导入。
+    * 右击工程,选择 `Build Path -> Configure Build Path`。
+    * 在 `Java Build Path` 对话框中,选择 `Source` 标签页,点击 `Add Folder`,勾选添加之前拷贝并解压的 
`java/` 目录。
+    * 点击 `Apply and Close` 完成。
+
+至此,FE 导入完成。Eclipse 中的工程目录大致如下:
+
+![](/images/eclipse-import-fe-project-1.png)
+
+## 运行单元测试
+
+在想要运行的单元测试文件上右击,选择 `Run As -> JUnit Test`。(如果要单步调试,则选择 `Debug As -> JUnit 
Test`)。
+
+如果出现以下错误:
+
+```
+java.lang.Exception: Method xxxx should have no parameters
+```
+
+则右击单元测试文件,选择 `Run As -> Run Configurations...`。(如果要单步调试,则选择 `Debug As -> Debug 
Configurations...`)。
+
+在 `Arguments` 标签页中的 `VM arguments` 中添加:
+
+```
+-javaagent:${settings.localRepository}/org/jmockit/jmockit/1.48/jmockit-1.48.jar
+```
+
+其中 `${settings.localRepository}` 要换成 maven lib 库的路径,如:
+
+```
+-javaagent:/Users/cmy/.m2/repository/org/jmockit/jmockit/1.48/jmockit-1.48.jar
+```
+
+之后在运行 `Run/Debug` 即可。
+
+## 运行 FE
+
+可以在 Ecplise 中直接启动一个 FE 进程,方便对代码进行调试。
+
+1. 创建一个运行目录:
+
+    ```
+    mkdir /path/to/doris/fe/run/
+    cd /path/to/doris/fe/run/
+    mkdir conf/ log/ palo-meta/
+    ```
+    
+2. 创建配置文件
+    
+    在第一步创建的 `conf/` 目录下创建配置文件 `fe.conf`。你可以直接将源码目录下 `conf/fe.conf` 拷贝过来并做简单修改。
+    
+3. 在 Ecplise 中找到 `src/main/java/org/apache/doris/PaloFe.java` 文件,右击选择 `Run As 
-> Run Configurations...`。在 `Environment` 标签页中添加如下环境变量:
+
+    * `DORIS_HOME: /path/to/doris/fe/run/`
+    * `PID_DIR: /path/to/doris/fe/run/`
+    * `LOG_DIR: /path/to/doris/fe/run/log`
+
+4. 右击 `PaloFe.java`,选择 `Run As -> Java Application`,则可以启动 FE。
+
+## 代码更新
+
+1. 更新词法、语法文件
+
+    如果修改了 `fe/src/main/cup/sql_parser.cup` 或者 
`fe/src/main/jflex/sql_scanner.flex` 文件。则需在 `fe/` 目录下执行以下命令:
+    
+    ```
+    mvn de.jflex:maven-jflex-plugin:1.4.3:generate
+    mvn net.sourceforge.czt.dev:cup-maven-plugin:1.6-cdh:generate
+    ```
+    
+    之后在 Eclipse 中刷新工程即可。
+    
+2. 更新 maven 依赖
+
+    如果更新了 `fe/pom.xml` 中的依赖,则需在 `fe/` 目录下执行以下命令:
+
+    `mvn -npr eclipse:eclipse -Dskip.plugin=true`
+    
+    之后在 Eclipse 中刷新工程即可。如无法更新,建议删除工程,并按照该文档重新导入一遍即可。
+
+## Import 顺序
+
+为了保持 Java 的 Import 顺序,请执行如下操作设定项目的 Import Order
+
+1. 创建文件 `fe_doris.importorder` 并写入以下内容:
+
+    ```
+    #Organize Import Order
+    #Wed Jul 01 16:42:47 CST 2020
+    4=javax
+    3=java
+    2=org
+    1=com
+    0=org.apache.doris
+    ```
+
+2. 打开 Eclipse 的偏好设置(Preferences),选择 `Java -> Code Style -> Organize 
Imports`。点击 `Import` 导入上述文件。
diff --git a/docs/zh-CN/developer-guide/fe-idea-dev.md 
b/docs/zh-CN/developer-guide/fe-idea-dev.md
index aa09c2a..ad1bf15 100644
--- a/docs/zh-CN/developer-guide/fe-idea-dev.md
+++ b/docs/zh-CN/developer-guide/fe-idea-dev.md
@@ -1,6 +1,6 @@
 ---
 {
-    "title": "windows下fe开发环境搭建",
+    "title": "FE 开发环境搭建 - Intellj IDEA",
     "language": "zh-CN"
 }
 ---
@@ -24,7 +24,7 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-# apache doris windows下fe开发环境搭建
+# 使用 Intellj IDEA 搭建 FE 开发环境
 
 ## 1.环境准备
 
@@ -40,17 +40,17 @@ $ sh build.sh --clean --fe
 
 然后将 gensrc目录打包,拿出来,如下图
 
-![image-20200624124200704](../../.vuepress/public/images/DEBUG1.png)
+![](/images/DEBUG1.png)
 
 2.在windows下解压gensrc.tar.gz,解压后的目录如下图:
 
-![image-20200624124420766](../../.vuepress/public/images/DEBUG2.png)
+![](/images/DEBUG2.png)
 
 3.进入build/java,将红色框出的部分整个拷贝到源码的fe/src/main/java目录下
 
 
 
-![image-20200624124550741](../../.vuepress/public/images/DEBUG3.png)
+![](/images/DEBUG3.png)
 
 ## 2.调试
 
@@ -58,7 +58,7 @@ $ sh build.sh --clean --fe
 
 2.在fe目录下创建下面红框标出的目录,并将webroot里的内容拷贝进去
 
-![image-20200624125009183](../../.vuepress/public/images/DEBUG4.png)
+![](/images/DEBUG4.png)
 
 ## 3.配置conf/fe.conf
 
@@ -143,7 +143,7 @@ mysql_service_nio_enabled = true
 
 在IDEA中设置运行环境变量
 
-![image-20200624125409626](../../.vuepress/public/images/DEBUG5.png)
+![](/images/DEBUG5.png)
 
 ## 5.启动fe
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to