TisonKun commented on a change in pull request #13188: URL: https://github.com/apache/flink/pull/13188#discussion_r474344537
########## File path: docs/flinkDev/building.zh.md ########## @@ -22,129 +22,132 @@ specific language governing permissions and limitations under the License. --> -This page covers how to build Flink {{ site.version }} from sources. +本篇主题是如何从版本 {{ site.version }} 的源码构建 Flink。 * This will be replaced by the TOC {:toc} -## Build Flink +## 构建 Flink -In order to build Flink you need the source code. Either [download the source of a release]({{ site.download_url }}) or [clone the git repository]({{ site.github_url }}). +首先需要准备源码。可以 [从发布版本下载源码]({{ site.download_url }})或者 [从 Git 库克隆 Flink 源码]({{ site.github_url }})。 -In addition you need **Maven 3** and a **JDK** (Java Development Kit). Flink requires **at least Java 8** to build. +还需要准备 **Maven 3** 和 **JDK** (Java开发套件)。Flink 依赖 **Java 8** 或更新的版本来进行构建。 -*NOTE: Maven 3.3.x can build Flink, but will not properly shade away certain dependencies. Maven 3.2.5 creates the libraries properly. +*注意:Maven 3.3.x 可以构建 Flink,但是不会去掉指定的依赖。Maven 3.2.5 可以很好地构建对应的库文件。 To build unit tests use Java 8u51 or above to prevent failures in unit tests that use the PowerMock runner.* +运行单元测试需要 Java 8u51 以上的版本来避免使用 PowerMock Runner 的单元测试失败。 -To clone from git, enter: +从 Git 克隆代码,输入: {% highlight bash %} git clone {{ site.github_url }} {% endhighlight %} -The simplest way of building Flink is by running: +最简单的构建 Flink 的方法,执行如下命令: {% highlight bash %} mvn clean install -DskipTests {% endhighlight %} -This instructs [Maven](http://maven.apache.org) (`mvn`) to first remove all existing builds (`clean`) and then create a new Flink binary (`install`). +上面的 [Maven](http://maven.apache.org) 指令 (`mvn`) 首先删除 (`clean`) 所有存在的构建,然后构建一个新的 Flink 运行包 (`install`)。 -To speed up the build you can skip tests, QA plugins, and JavaDocs: +为了加速构建,可以跳过测试,QA 的插件和 JavaDocs 的生成,执行如下命令: {% highlight bash %} mvn clean install -DskipTests -Dfast {% endhighlight %} -## 构建PyFlink +## 构建 PyFlink #### 先决条件 -1. 构建Flink +1. 构建 Flink - 如果您想构建一个可用于pip安装的PyFlink包,您需要先构建Flink工程,如[构建Flink](#build-flink)中所述。 + 如果想构建一个可用于 pip 安装的 PyFlink 包,需要先构建 Flink 工程,如 [构建 Flink](#build-flink) 中所述。 -2. Python的版本为3.5, 3.6 或者 3.7. +2. Python 的版本为 3.5, 3.6 或者 3.7. ```shell $ python --version # the version printed here must be 3.5, 3.6 or 3.7 ``` -3. 构建PyFlink的Cython扩展模块(可选的) +3. 构建 PyFlink 的 Cython 扩展模块(可选的) - 为了构建PyFlink的Cython扩展模块,您需要C编译器。在不同操作系统上安装C编译器的方式略有不同: + 为了构建 PyFlink 的 Cython 扩展模块,需要 C 编译器。在不同操作系统上安装 C 编译器的方式略有不同: - * **Linux** Linux操作系统通常预装有GCC。否则,您需要手动安装。例如,您可以在Ubuntu或Debian上使用命令`sudo apt-get install build-essential`安装。 + * **Linux** Linux 操作系统通常预装有 GCC。否则,需要手动安装。例如,可以在 Ubuntu 或 Debian 上使用命令`sudo apt-get install build-essential`安装。 - * **Mac OS X** 要在Mac OS X上安装GCC,您需要下载并安装 [Xcode命令行工具](https://developer.apple.com/downloads/index.action),该工具可在Apple的开发人员页面中找到。 + * **Mac OS X** 要在 Mac OS X 上安装 GCC,你需要下载并安装 [Xcode 命令行工具](https://developer.apple.com/downloads/index.action + ),该工具可在 Apple 的开发人员页面中找到。 - 您还需要使用以下命令安装依赖项: + 还需要使用以下命令安装依赖项: ```shell $ python -m pip install -r flink-python/dev/dev-requirements.txt ``` #### 安装 -进入Flink源码根目录,并执行以下命令,构建PyFlink的源码发布包和wheel包: +进入 Flink 源码根目录,并执行以下命令,构建 PyFlink 的源码发布包和 wheel 包: {% highlight bash %} cd flink-python; python setup.py sdist bdist_wheel {% endhighlight %} -构建好的源码发布包和wheel包位于`./flink-python/dist/`目录下。它们均可使用pip安装,比如: +构建好的源码发布包和 wheel 包位于`./flink-python/dist/`目录下。它们均可使用 pip 安装,比如: {% highlight bash %} python -m pip install dist/*.tar.gz {% endhighlight %} -## Dependency Shading +## 依赖屏蔽 -Flink [shades away](https://maven.apache.org/plugins/maven-shade-plugin/) some of the libraries it uses, in order to avoid version clashes with user programs that use different versions of these libraries. Among the shaded libraries are *Google Guava*, *Asm*, *Apache Curator*, *Apache HTTP Components*, *Netty*, and others. +Flink [依赖屏蔽](https://maven.apache.org/plugins/maven-shade-plugin/) 一些它使用的包,这样做是为了避免与程序员自己引入的包的存在的可能的版本冲突。屏蔽掉的包包括 *Google Guava*,*Asm*,*Apache Curator*,*Apache HTTP Components*,*Netty* 等。 -The dependency shading mechanism was recently changed in Maven and requires users to build Flink slightly differently, depending on their Maven version: +这种依赖屏蔽机制最近在 Maven 中有所改变。需要用户根据 Maven 的的不同版本来执行不同的命令。 -**Maven 3.1.x and 3.2.x** -It is sufficient to call `mvn clean install -DskipTests` in the root directory of Flink code base. +**对于Maven 3.1.x and 3.2.x** +直接在 Flink 源码根目录执行命令 `mvn clean install -DskipTests` 就足够了。 **Maven 3.3.x** -The build has to be done in two steps: First in the base directory, then in the distribution project: +如下的构建需要两步走:第一步需要在基础目录下执行编译构建;第二步需要在编译后的 flink-dist 目录下执行: {% highlight bash %} mvn clean install -DskipTests cd flink-dist mvn clean install {% endhighlight %} -*Note:* To check your Maven version, run `mvn --version`. +*注意:* 查看 Maven 的版本,执行 `mvn --version`. Review comment: ```suggestion *注意:* 运行 `mvn --version` 以查看 Maven 的版本。 ``` ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org