flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-9222) Add a Gradle Quickstart
Date Mon, 13 Aug 2018 15:42:00 GMT

    [ https://issues.apache.org/jira/browse/FLINK-9222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16578467#comment-16578467
] 

ASF GitHub Bot commented on FLINK-9222:
---------------------------------------

twalthr commented on a change in pull request #105: [FLINK-9222] add gradle quickstart script
URL: https://github.com/apache/flink-web/pull/105#discussion_r209653708
 
 

 ##########
 File path: q/gradle-quickstart.sh
 ##########
 @@ -0,0 +1,226 @@
+#!/bin/bash
+
+################################################################################
+#  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.
+################################################################################
+
+declare -r TRUE=0
+declare -r FALSE=1
+
+# takes a string and returns true if it seems to represent "yes"
+function isYes() {
+  local x=$1
+  [ $x = "y" -o $x = "Y" -o $x = "yes" ] && echo $TRUE; return
+  echo $FALSE
+}
+
+function mkDir() {
+  local x=$1
+  echo ${x// /-} | tr '[:upper:]' '[:lower:]'
+}
+
+function mkPackage() {
+  local x=$1
+  echo ${x//./\/}
+}
+
+defaultProjectName="quickstart"
+defaultOrganization="org.myorg.quickstart"
+defaultVersion="0.1-SNAPSHOT"
+defaultScalaBinaryVersion="2.11"
+defaultFlinkVersion="1.6-SNAPSHOT"
+
+echo "This script creates a Flink project using Java and Gradle."
+
+while [ $TRUE ]; do
+
+  echo ""
+  read -p "Project name ($defaultProjectName): " projectName
+  projectName=${projectName:-$defaultProjectName}
+  read -p "Organization ($defaultOrganization): " organization
+  organization=${organization:-$defaultOrganization}
+  read -p "Version ($defaultVersion): " version
+  version=${version:-$defaultVersion}
+  read -p "Scala version ($defaultScalaBinaryVersion): " scalaBinaryVersion
+  scalaBinaryVersion=${scalaBinaryVersion:-$defaultScalaBinaryVersion}
+  read -p "Flink version ($defaultFlinkVersion): " flinkVersion
+  flinkVersion=${flinkVersion:-$defaultFlinkVersion}
+
+  echo ""
+  echo "-----------------------------------------------"
+  echo "Project Name: ${projectName}"
+  echo "Organization: ${organization}"
+  echo "Version: ${version}"
+  echo "Scala binary version: ${scalaBinaryVersion}"
+  echo "Flink version: ${flinkVersion}"
+  echo "-----------------------------------------------"
+  read -p "Create Project? (Y/n): " createProject
+  createProject=${createProject:-y}
+
+  [ "$(isYes "${createProject}")" = "$TRUE" ] && break
+
+done
+
+directoryName=$(mkDir "${projectName}")
+
+echo "Creating Flink project under ${directoryName}"
+
+mkdir -p ${directoryName}
+cd ${directoryName}
+
+# Create the README file
+
+cat > README <<EOF
+A Flink application project using Java and Gradle.
+
+To package your job for submission to Flink, use: 'gradle shadowJar'
+
+To run and test your application with an embedded instance of Flink use: 'gradle run'
+EOF
+
+# Create the gradle build files
+
+cat > settings.gradle <<EOF
+rootProject.name = '${projectName}'
+EOF
+
+cat > build.gradle <<EOF
+buildscript {
+    repositories {
+        jcenter() // this applies only to the Gradle 'Shadow' plugin
+    }
+    dependencies {
+        classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.4'
+    }
+}
+
+plugins {
+    id 'java'
+    id 'application'
+    // shadow plugin to produce fat JARs
+    id 'com.github.johnrengelman.shadow' version '2.0.4'
+}
+
+
+// artifact properties
+group = '${organization}'
+version = '${version}'
+mainClassName = '${organization}.StreamingJob'
+description = """Flink Quickstart Job"""
+
+ext {
+    javaVersion = '1.8'
+    flinkVersion = '${flinkVersion}'
+    scalaBinaryVersion = '${scalaBinaryVersion}'
+    slf4jVersion = '1.7.7'
+    log4jVersion = '1.2.17'
+}
+
+
+sourceCompatibility = javaVersion
+targetCompatibility = javaVersion
+tasks.withType(JavaCompile) {
+	options.encoding = 'UTF-8'
+}
+
+applicationDefaultJvmArgs = ["-Dlog4j.configuration=log4j.properties"]
+
+task wrapper(type: Wrapper) {
+    gradleVersion = '3.1'
+}
+
+// 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 "flinkShadowJar"
configuration!
+configurations {
+    flinkShadowJar // dependencies which go into the shadowJar
+
+    // always exclude these (also from transitive dependencies) since they are provided by
Flink
+    flinkShadowJar.exclude group: 'org.apache.flink', module: 'force-shading'
+    flinkShadowJar.exclude group: 'com.google.code.findbugs', module: 'jsr305'
+    flinkShadowJar.exclude group: 'org.slf4j'
+    flinkShadowJar.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}"
+
+    // Add connector dependencies here.
 
 Review comment:
   Not only `connector`. In general I would make this section more prominent. Maybe using
   ```
   // --------------------------------------------------------------
   // Add dependencies here that should NOT be part of the 
   // shadow jar and are provided in the lib folder of Flink
   // --------------------------------------------------------------
   ...
   // --------------------------------------------------------------
   // Add dependencies here that should be part of the shadow jar
   // --------------------------------------------------------------
   ```

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Add a Gradle Quickstart
> -----------------------
>
>                 Key: FLINK-9222
>                 URL: https://issues.apache.org/jira/browse/FLINK-9222
>             Project: Flink
>          Issue Type: Improvement
>          Components: Project Website, Quickstarts
>            Reporter: Nico Kruber
>            Assignee: Nico Kruber
>            Priority: Critical
>              Labels: pull-request-available
>
> Having a proper project template helps a lot in getting dependencies right. For example,
setting the core dependencies to "provided", the connector / library dependencies to "compile",
etc.
> The Maven quickstarts are in good shape by now, but there is none for Gradle and Gradle
users to get this wrong quite often.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message