XComp commented on code in PR #23544:
URL: https://github.com/apache/flink/pull/23544#discussion_r1371232099


##########
tools/releasing/check_java_maven_versions.sh:
##########
@@ -0,0 +1,40 @@
+#!/usr/bin/env 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.
+#
+
+# Define the required versions
+required_java_version="1.8"
+required_maven_version="3.8.6"
+
+# Check Java version
+java_version=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}')
+if [[ "$java_version" == "$required_java_version"* ]]; then
+    echo "Java version is correct: $java_version"
+else
+    echo "Java version is incorrect. Required version: $required_java_version, 
but it is $java_version"
+    exit 1
+fi
+
+# Check Maven version
+maven_version=$(mvn -v | grep -oE 'Apache Maven [0-9]+\.[0-9]+\.[0-9]+' | awk 
'{print $3}')
+if [[ "$maven_version" == "$required_maven_version" ]]; then
+    echo "Maven version is correct: $maven_version"
+else
+    echo "Maven version is incorrect. Required version: 
$required_maven_version, but it is $maven_version"
+    exit 1
+fi

Review Comment:
   ```suggestion
   MVN=${MVN:-mvn}
   
   if which $MVN > /dev/null; then
     mvn -q -Prelease -pl flink-annotations validate | grep -v ERROR
   else
     echo "No valid Maven binaries specified."
     exit 1
   fi
   ```
   The code above would do the same trick without needing to specify the 
versions. One could argue that we don't even need the if logic because someone 
would have had to specify an invalid Maven binary deliberately to get into the 
else branch.



##########
tools/releasing/create_source_release.sh:
##########
@@ -17,6 +17,9 @@
 # limitations under the License.
 #
 
+## check required Java and Maven version
+. check_java_maven_versions.sh

Review Comment:
   I would still object adding this check here because we're not using Java or 
Maven in this script. We could even remove the line below where the `MVN` 
variable is defined.



##########
tools/releasing/create_binary_release.sh:
##########
@@ -17,6 +17,9 @@
 # limitations under the License.
 #
 
+## check required Java and Maven version

Review Comment:
   Checking the versions is the first thing that will happen in this script 
(after creating some directory). Therefore, this check is already happening 
before doing anything else.



##########
tools/releasing/deploy_staging_jars.sh:
##########
@@ -17,6 +17,9 @@
 # limitations under the License.
 #
 
+## check required Java and Maven version
+. check_java_maven_versions.sh

Review Comment:
   Here, we don't have any other commands happening before the Maven call. 
Therefore, we would get the version check before anything else happens as well.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to