XComp commented on code in PR #683: URL: https://github.com/apache/flink-web/pull/683#discussion_r1366737354
########## _include/q/gradle-quickstart.sh: ########## @@ -38,14 +38,22 @@ function mkPackage() { echo ${x//./\/} } +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; + fi + awk -F'"' '/'$1' = "/{print $2}' docs/config.toml Review Comment: ```suggestion awk -F'"' '/'$1'[ ]*=[ ]*"/{print $2}' docs/config.toml ``` You want to make this script more future prove by allowing different number of spaces ########## _include/q/gradle-quickstart.sh: ########## @@ -38,14 +38,22 @@ function mkPackage() { echo ${x//./\/} } +function extract_parameter() { Review Comment: What about creating a _utils.sh script within `_include/q/` and move this function to this script. We're using it in multiple locations. That would reduce the code redundancy. Also some other functions (from `gradle-quickstart.sh` and `sbt-quickstart.sh` can be collected in that file). WDYT? ########## _include/q/gradle-quickstart.sh: ########## @@ -38,14 +38,22 @@ function mkPackage() { echo ${x//./\/} } +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; + fi + awk -F'"' '/'$1' = "/{print $2}' docs/config.toml Review Comment: ```suggestion awk -F'"' '/'$1' = "/{print $2}' docs/config.toml ``` I didn't mention that in my initial proposal (sorry for that) but it might make sense to also validate the returned value (to ensure that we actually found a value). ########## docs/config.toml: ########## @@ -43,6 +43,11 @@ posts = "/:year/:month/:day/:title/" FlinkKubernetesOperatorStableShortVersion = "1.6" FlinkTableStoreStableVersion = "0.3.0" FlinkTableStoreStableShortVersion = "0.3" + ScalaVersion="2.12.7" + ScalaShortVersion="2.12" + JavaVersion="1.8" + Slf4jVersion="1.7.36" + Log4jVersion="2.17.1" Review Comment: ```suggestion ScalaVersion = "2.12.7" ScalaShortVersion = "2.12" JavaVersion = "1.8" Slf4jVersion = "1.7.36" Log4jVersion = "2.17.1" ``` Could we align the format with the other examples? ########## _include/q/quickstart-scala-SNAPSHOT.sh: ########## @@ -21,10 +21,20 @@ PACKAGE=quickstart +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; + fi + awk -F'"' '/'$1' = "/{print $2}' docs/config.toml +} + +defaultFlinkVersionSnapShot="$(extract_parameter 'FlinkStableShortVersion')-SNAPSHOT" + mvn org.apache.maven.plugins:maven-archetype-plugin:2.4:generate \ -DarchetypeGroupId=org.apache.flink \ -DarchetypeArtifactId=flink-quickstart-scala \ - -DarchetypeVersion=${1:-1.17-SNAPSHOT} \ + -DarchetypeVersion=${defaultFlinkVersionSnapShot} \ Review Comment: ```suggestion -DarchetypeVersion=${1:-${defaultFlinkVersionSnapShot}} \ ``` you omitted the parameter here ########## _include/q/quickstart-scala.sh: ########## @@ -21,10 +21,20 @@ PACKAGE=quickstart +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; + fi + awk -F'"' '/'$1' = "/{print $2}' docs/config.toml +} + +defaultFlinkVersion="$(extract_parameter 'FlinkStableVersion')" + mvn archetype:generate \ -DarchetypeGroupId=org.apache.flink \ -DarchetypeArtifactId=flink-quickstart-scala \ - -DarchetypeVersion=${1:-1.17.0} \ + -DarchetypeVersion=${defaultFlinkVersion} \ Review Comment: ```suggestion -DarchetypeVersion=${1:-${defaultFlinkVersion}} \ ``` parameter omitted ########## _include/q/sbt-quickstart.sh: ########## @@ -97,15 +105,15 @@ echo "ThisBuild / resolvers ++= Seq( Resolver.mavenLocal ) -name := \"Flink Project\" +name := \"$projectName\" -version := \"0.1-SNAPSHOT\" +version := \"$version\" -organization := \"org.example\" +organization := \"$organization\" -ThisBuild / scalaVersion := \"2.12.7\" +ThisBuild / scalaVersion := \"$scalaVersion\" -val flinkVersion = \"1.16.1\" +val flinkVersion = \"$flinkVersion\" Review Comment: Good catch :-) ########## _include/q/sbt-quickstart.sh: ########## @@ -38,11 +38,19 @@ function mkPackage() { echo ${x//./\/} } +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; + fi + awk -F'"' '/'$1' = "/{print $2}' docs/config.toml +} + defaultProjectName="Flink Project" defaultOrganization="org.example" defaultVersion="0.1-SNAPSHOT" -defaultScalaVersion="2.12.7" -defaultFlinkVersion="1.17.0" +defaultFlinkVersion="$(extract_parameter 'FlinkStableVersion')" +defaultScalaVersion="$(extract_parameter 'ScalaVersion')" Review Comment: ```suggestion defaultScalaVersion="$(extract_parameter 'ScalaVersion')" defaultFlinkVersion="$(extract_parameter 'FlinkStableVersion')" ``` let's stick to the order to make the diff more readable. ########## _include/q/quickstart.sh: ########## @@ -21,10 +21,20 @@ PACKAGE=quickstart +function extract_parameter() { + if [[ "$#" != 1 ]]; then + echo "Fatal error: No parameter or too many parameter passed: $@" + exit 1; + fi + awk -F'"' '/'$1' = "/{print $2}' docs/config.toml +} + +defaultFlinkVersion="$(extract_parameter 'FlinkStableVersion')" + mvn archetype:generate \ -DarchetypeGroupId=org.apache.flink \ -DarchetypeArtifactId=flink-quickstart-java \ - -DarchetypeVersion=${1:-1.17.0} \ + -DarchetypeVersion=${defaultFlinkVersion} \ Review Comment: ```suggestion -DarchetypeVersion=${1:-${defaultFlinkVersion}} \ ``` parameter omitted -- 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. To unsubscribe, e-mail: issues-unsubscr...@flink.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org