Building Flink from Source
This page covers how to build Flink 1.10.0 from sources.
Build Flink
In order to build Flink you need the source code. Either download the source of a release or clone the git repository.
In addition you need Maven 3 and a JDK (Java Development Kit). Flink requires at least Java 8 to build.
NOTE: Maven 3.3.x can build Flink, but will not properly shade away certain dependencies. Maven 3.2.5 creates the libraries properly.To build unit tests use Java 8u51 or above to prevent failures in unit tests that use the PowerMock runner.
To clone from git, enter:
git clone https://github.com/apache/flink
The simplest way of building Flink is by running:
mvn clean install -DskipTests
This instructs Maven (mvn
) to first remove all existing builds (clean
) and then create a new Flink binary (install
).
To speed up the build you can skip tests, QA plugins, and JavaDocs:
mvn clean install -DskipTests -Dfast
Build PyFlink
If you want to build a PyFlink package that can be used for pip installation, you need to build Flink jars first, as described in Build Flink.Then go to the root directory of flink source code and run this command to build the sdist package and wheel package:
cd flink-python; python setup.py sdist bdist_wheel
Note Python 3.5 or higher is required to build PyFlink.
The sdist and wheel package will be found under ./flink-python/dist/
. Either of them could be used for pip installation, such as:
python -m pip install dist/*.tar.gz
Dependency Shading
Flink shades away 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.
The dependency shading mechanism was recently changed in Maven and requires users to build Flink slightly differently, depending on their Maven version:
Maven 3.1.x and 3.2.xIt is sufficient to call mvn clean install -DskipTests
in the root directory of Flink code base.
Maven 3.3.xThe build has to be done in two steps: First in the base directory, then in the distribution project:
mvn clean install -DskipTests
cd flink-dist
mvn clean install
Note: To check your Maven version, run mvn —version
.
Hadoop Versions
Please see the Hadoop integration section on how to handle Hadoop classes and versions.
Scala Versions
Info Users that purely use the Java APIs and libraries can ignore this section.
Flink has APIs, libraries, and runtime modules written in Scala. Users of the Scala API and libraries may have to match the Scala version of Flink with the Scala version of their projects (because Scala is not strictly backwards compatible).
Since version 1.7 Flink builds with Scala version 2.11 (default) and 2.12.
To build FLink against Scala 2.12, issue the following command:
mvn clean install -DskipTests -Dscala-2.12
Encrypted File Systems
If your home directory is encrypted you might encounter a java.io.IOException: File name too long
exception. Some encrypted file systems, like encfs used by Ubuntu, do not allow long filenames, which is the cause of this error.
The workaround is to add:
<args>
<arg>-Xmax-classfile-name</arg>
<arg>128</arg>
</args>
in the compiler configuration of the pom.xml
file of the module causing the error. For example, if the error appears in the flink-yarn
module, the above code should be added under the <configuration>
tag of scala-maven-plugin
. See this issue for more information.