adoroszlai commented on code in PR #4596:
URL: https://github.com/apache/ozone/pull/4596#discussion_r1176810786


##########
hadoop-ozone/dev-support/checks/native_check.sh:
##########
@@ -0,0 +1,50 @@
+#!/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.
+
+function get_rocks_native_git_sha() {
+    echo "Getting Rocks Native Git sha"
+    echo
+    # Getting the latest git hash for the ./hadoop-hdds/rocks-native directory
+    echo "git log -n 1 --format=\"%h\" ./hadoop-hdds/rocks-native"
+    ROCKS_NATIVE_GIT_SHA=$(git log -n 1 --format="%h" 
./hadoop-hdds/rocks-native)
+    echo "ROCKS_NATIVE_GIT_SHA = ${ROCKS_NATIVE_GIT_SHA}"
+    readonly ROCKS_NATIVE_GIT_SHA
+}
+
+function init_native_maven_opts() {
+    get_rocks_native_git_sha
+    PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q 
-DforceStdout)
+    # Parsing out version number from project version by getting the first 
occurance of '-'.
+    # If project version is 1.4.0-SNAPSHOT, VERSION_NUMBER = 1.4.0
+    VERSION_NUMBER=$(echo "${PROJECT_VERSION}" | cut -f1 -d'-')
+    # Adding rocks native sha after the version number in the project version.
+    # EXPECTED_ROCK_NATIVE_VERSION = 1.4.0.<rocks native git sha>-SNAPSHOT
+    
EXPECTED_ROCKS_NATIVE_VERSION=${VERSION_NUMBER}".${ROCKS_NATIVE_GIT_SHA}"${PROJECT_VERSION:${#VERSION_NUMBER}}
+    echo "Checking Maven repo contains hdds-rocks-native of version 
${EXPECTED_ROCKS_NATIVE_VERSION}"
+    mvn --non-recursive dependency:get 
-Dartifact=org.apache.ozone:hdds-rocks-native:${EXPECTED_ROCKS_NATIVE_VERSION} 
-q
+
+    EXPECTED_ROCKS_NATIVE_VERSION_EXISTS=$?

Review Comment:
   _compile_ check builds Ozone from source tarball, not a git repo, so `git 
log` does not work.
   
   ```
   git log -n 1 --format="%h" ./hadoop-hdds/rocks-native
   fatal: not a git repository (or any of the parent directories): .git
   ROCKS_NATIVE_GIT_SHA = 
   Checking Maven repo contains hdds-rocks-native of version 1.4.0.-SNAPSHOT
   Error:  Failed to execute goal 
org.apache.maven.plugins:maven-dependency-plugin:3.0.2:get (default-cli) on 
project ozone-main: Couldn't download artifact: 
org.eclipse.aether.resolution.DependencyResolutionException: Could not find 
artifact org.apache.ozone:hdds-rocks-native:jar:1.4.0.-SNAPSHOT in 
apache.snapshots.https 
(https://repository.apache.org/content/repositories/snapshots) -> [Help 1]
   Error:  
   Error:  To see the full stack trace of the errors, re-run Maven with the -e 
switch.
   Error:  Re-run Maven using the -X switch to enable full debug logging.
   Error:  
   Error:  For more information about the errors and possible solutions, please 
read the following articles:
   Error:  [Help 1] 
http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
   Building hdds-rocks-native module as version 1.4.0.-SNAPSHOT was not found
   ```
   
   Let's skip `dependency:get` if `ROCKS_NATIVE_GIT_SHA` is empty.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to