Github user NicoK commented on a diff in the pull request:
https://github.com/apache/flink/pull/5900#discussion_r201310579
--- Diff: docs/quickstart/java_api_quickstart.md ---
@@ -108,16 +118,201 @@ In Eclipse, choose
box: `-Xmx800m`.
In IntelliJ IDEA recommended way to change JVM options is from the `Help |
Edit Custom VM Options` menu. See [this
article](https://intellij-support.jetbrains.com/hc/en-us/articles/206544869-Configuring-JVM-options-and-platform-properties)
for details.
-## Build Project
+### 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, the Flink
-can run time application from the JAR file without additionally specifying
the main class.
+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__:
+
+<ul class="nav nav-tabs" style="border-bottom: none;">
+ <li class="active"><a href="#gradle-example"
data-toggle="tab"><strong>Gradle example</strong></a></li>
+ <li><a href="#gradle-script" data-toggle="tab">Run the
<strong>quickstart script</strong></a></li>
+</ul>
+<div class="tab-content">
+ <div class="tab-pane active" id="gradle-example">
+
+ <ul class="nav nav-tabs" style="border-bottom: none;">
+ <li class="active"><a href="#gradle-build"
data-toggle="tab"><tt>build.gradle</tt></a></li>
+ <li><a href="#gradle-settings"
data-toggle="tab"><tt>settings.gradle</tt></a></li>
+ </ul>
+ <div class="tab-content">
+ <div class="tab-pane active" id="gradle-build">
+ {% highlight gradle %}
+buildscript {
+ repositories {
+ jcenter() // this applies only to the Gradle 'Shadow' plugin
+ }
+ dependencies {
+ classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.3'
+ }
+}
+
+plugins {
+ id 'java'
+ id 'application'
+ // shadow plugin to produce fat JARs
+ id 'com.github.johnrengelman.shadow' version '2.0.3'
+}
+
+
+// artifact properties
+group = 'org.myorg.quickstart'
+version = '0.1-SNAPSHOT'
+mainClassName = 'org.myorg.quickstart.StreamingJob'
+description = """Flink Quickstart Job"""
+
+ext {
+ javaVersion = '1.8'
+ flinkVersion = '1.6-SNAPSHOT'
+ scalaBinaryVersion = '2.11'
+ slf4jVersion = '1.7.7'
+ log4jVersion = '1.2.17'
+}
+
+
+sourceCompatibility = javaVersion
+targetCompatibility = javaVersion
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
+
+applicationDefaultJvmArgs = ["-Dlog4j.configuration=log4j.properties"]
+
+// declare where to find the dependencies of your project
+repositories {
+ mavenCentral()
+ maven { url
"https://repository.apache.org/content/repositories/snapshots/" }
+}
+
+// NOTE: We cannot use "compileOnly" or "shadow" configurations since then
we could not run code
+// in the IDE or with "gradle run". We also cannot exclude transitive
dependencies from the
+// shadowJar yet (see https://github.com/johnrengelman/shadow/issues/159).
+// -> Explicitly define the // libraries we want to be included in the
"myShadowJar" configuration!
+configurations {
+ myShadowJar // dependencies which go into the shadowJar
+
+ // always exclude these (also from transitive dependencies) since they
are provided by Flink
+ myShadowJar.exclude group: 'org.apache.flink', module: 'force-shading'
+ myShadowJar.exclude group: 'com.google.code.findbugs', module: 'jsr305'
+ myShadowJar.exclude group: 'org.slf4j'
+ myShadowJar.exclude group: 'log4j'
+}
+
+// declare the dependencies for your production and test code
+dependencies {
+ compile "org.apache.flink:flink-java:${flinkVersion}"
+ compile
"org.apache.flink:flink-streaming-java_${scalaBinaryVersion}:${flinkVersion}"
+
+ //myShadowJar
"org.apache.flink:flink-connector-kafka-0.11_${scalaBinaryVersion}:${flinkVersion}"
+
+ compile "log4j:log4j:${log4jVersion}"
+ compile "org.slf4j:slf4j-log4j12:${slf4jVersion}"
+
+ testCompile "junit:junit:4.12"
+}
+
+// make compileOnly dependencies available for tests:
+sourceSets {
+ main.runtimeClasspath += configurations.myShadowJar
+ main.runtimeClasspath += configurations.myShadowJar
+
+ test.compileClasspath += configurations.myShadowJar
+ test.runtimeClasspath += configurations.myShadowJar
+}
+
+jar {
+ manifest {
+ attributes 'Built-By': System.getProperty('user.name'),
+ 'Build-Jdk': System.getProperty('java.version')
+ }
+}
+
+shadowJar {
+ configurations = [project.configurations.myShadowJar]
+}
+ {% endhighlight %}
+ </div>
+ <div class="tab-pane" id="gradle-settings">
+ {% highlight gradle %}
+rootProject.name = 'quickstart'
+ {% endhighlight %}
+ </div>
+ </div>
+ </div>
+
+ <div class="tab-pane" id="gradle-script">
+ {% highlight bash %}
+ $ curl https://flink.apache.org/q/gradle-quickstart.sh | bash
+ {% endhighlight %}
+ This allows you to <strong>name your newly created project</strong>.
It will interactively ask
+ you for the project name, organization (also used for the package
name), project version,
+ Scala and Flink version.
+ </div>
+</div>
+
+### Inspect Project
+
+There will be a new directory in your working directory based on the
+project name you provided, e.g. for `quickstart`:
+
+{% highlight bash %}
+$ tree quickstart/
+quickstart/
+âââ README
+âââ build.gradle
+âââ settings.gradle
+âââ src
+ âââ main
+ âââ java
+ â  âââ org
+ â  âââ myorg
+ â  âââ quickstart
+ â  âââ BatchJob.java
+ â  âââ StreamingJob.java
+ âââ resources
+ âââ log4j.properties
+{% endhighlight %}
+
+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](https://projects.eclipse.org/projects/tools.buildship) plugin.
--- End diff --
just checked - seems to be working (you need to manually select a gradle
version >= 3.0 because the default gradle wrapper uses 2.14 which is too old) -
I added appropriate comments into the fixup commit
---