Flink projects can be built with different build tools.
In order to get started quickly, Flink provides project templates for the following build tools:
This allows you to name your newly created project. It will interactively ask you for the groupId, artifactId, and package name.
Inspect Project
There will be a new directory in your working directory. If you’ve used
the curl approach, the directory is called quickstart. Otherwise,
it has the name of your artifactId:
The sample project is a Maven project, which contains two classes: StreamingJob and BatchJob are the basic skeleton programs for a DataStream and DataSet program.
The main method is the entry point of the program, both for in-IDE testing/execution and for proper deployments.
We recommend you import this project into your IDE to develop and
test it. IntelliJ IDEA supports Maven projects out of the box.
If you use Eclipse, the m2e plugin
allows to import Maven projects.
Some Eclipse bundles include that plugin by default, others require you
to install it manually.
Please note: The default JVM heapsize for Java may be too
small for Flink. You have to manually increase it.
In Eclipse, choose Run Configurations -> Arguments and write into the VM Arguments box: -Xmx800m.
In IntelliJ IDEA recommended way to change JVM options is from the Help | Edit Custom VM Options menu. See this article for details.
Build Project
If you want to build/package your project, go to your project directory and
run the ‘mvn clean package’ command.
You will find a JAR file that contains your application, plus connectors and libraries
that you may have added as dependencies to the application: target/<artifact-id>-<version>.jar.
Note: If you use a different class than StreamingJob as the application’s main class / entry point,
we recommend you change the mainClass setting in the pom.xml file accordingly. That way, Flink
can run the application from the JAR file without additionally specifying the main class.
Gradle
Requirements
The only requirements are working Gradle 3.x (or higher) and Java 8.x installations.
Create Project
Use one of the following commands to create a project:
This allows you to name your newly created project. It will interactively ask
you for the project name, organization (also used for the package name), project version,
Scala and Flink version.
Inspect Project
There will be a new directory in your working directory based on the
project name you provided, e.g. for quickstart:
The sample project is a Gradle project, which contains two classes: StreamingJob and BatchJob are the basic skeleton programs for a DataStream and DataSet program.
The main method is the entry point of the program, both for in-IDE testing/execution and for proper deployments.
We recommend you import this project into your IDE to develop and
test it. IntelliJ IDEA supports Gradle projects after installing the Gradle plugin.
Eclipse does so via the Eclipse Buildship plugin
(make sure to specify a Gradle version >= 3.0 in the last step of the import wizard; the shadow plugin requires it).
You may also use Gradle’s IDE integration
to create project files from Gradle.
Please note: The default JVM heapsize for Java may be too
small for Flink. You have to manually increase it.
In Eclipse, choose Run Configurations -> Arguments and write into the VM Arguments box: -Xmx800m.
In IntelliJ IDEA recommended way to change JVM options is from the Help | Edit Custom VM Options menu. See this article for details.
Build Project
If you want to build/package your project, go to your project directory and
run the ‘gradle clean shadowJar’ command.
You will find a JAR file that contains your application, plus connectors and libraries
that you may have added as dependencies to the application: build/libs/<project-name>-<version>-all.jar.
Note: If you use a different class than StreamingJob as the application’s main class / entry point,
we recommend you change the mainClassName setting in the build.gradle file accordingly. That way, Flink
can run the application from the JAR file without additionally specifying the main class.
Next Steps
Write your application!
If you are writing a streaming application and you are looking for inspiration what to write,
take a look at the Stream Processing Application Tutorial.
If you are writing a batch processing application and you are looking for inspiration what to write,
take a look at the Batch Application Examples.