Skip to content

Commit

Permalink
Make it compile using both scala 2.12 and scala 2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
Kontinuation committed Nov 9, 2022
1 parent e4a46a5 commit 629098d
Show file tree
Hide file tree
Showing 6 changed files with 121 additions and 10 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ on:

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
scala: [2.12, 2.11]
steps:
- uses: actions/checkout@v3
- name: Set up JDK 1.8
Expand All @@ -27,5 +28,11 @@ jobs:
java-version: 8
distribution: 'temurin'
cache: maven
- name: Change scala version to ${{matrix.scala}}
run: bash ./build/change-scala-version.sh ${{matrix.scala}}
- name: Build with Maven
run: mvn -B package --file pom.xml
- uses: actions/upload-artifact@v3
with:
name: geomesa-sql-dist-package-${{matrix.scala}}
path: geomesa-sql-dist/target/*.tar.gz
80 changes: 80 additions & 0 deletions build/change-scala-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/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.
#

set -e

VALID_VERSIONS=( 2.11 2.12 )

SCALA_2_11_VERSION="2.11.7"
SCALA_2_12_VERSION="2.12.13"

usage() {
echo "Usage: $(basename $0) [-h|--help] <version>
where :
-h| --help Display this help text
valid version values : ${VALID_VERSIONS[*]}
" 1>&2
exit 1
}

if [[ ($# -ne 1) || ( $1 == "--help") || $1 == "-h" ]]; then
usage
fi

TO_VERSION=$1

check_scala_version() {
for i in ${VALID_VERSIONS[*]}; do [ $i = "$1" ] && return 0; done
echo "Invalid Scala version: $1. Valid versions: ${VALID_VERSIONS[*]}" 1>&2
exit 1
}

check_scala_version "$TO_VERSION"

if [ $TO_VERSION = "2.12" ]; then
FULL_VERSION="2.12.13"
FROM_VERSION="2.11"
else
FULL_VERSION="2.11.7"
FROM_VERSION="2.12"
fi

sed_i() {
sed -e "$1" "$2" > "$2.tmp" && mv "$2.tmp" "$2"
}

export -f sed_i

BASEDIR=$(dirname $0)/..
find "$BASEDIR" -name 'pom.xml' -not -path '*target*' -print \
-exec bash -c "sed_i 's/\(artifactId.*\)_'$FROM_VERSION'/\1_'$TO_VERSION'/g' {}" \;

# Also update <scala.binary.version> in parent POM
# Match any scala binary version to ensure idempotency
sed_i '1,/<scala\.binary\.version>[0-9]*\.[0-9]*</s/<scala\.binary\.version>[0-9]*\.[0-9]*</<scala.binary.version>'$TO_VERSION'</' \
"$BASEDIR/pom.xml"

# Also update <scala.version> in parent POM
sed_i '1,/<scala\.version>[0-9]*\.[0-9]*\.[0-9]*</s/<scala\.version>[0-9]*\.[0-9]*\.[0-9]*</<scala.version>'$FULL_VERSION'</' \
"$BASEDIR/pom.xml"

# Update enforcer rules
sed_i 's|<exclude>\*:\*_'$TO_VERSION'</exclude>|<exclude>*:*_'$FROM_VERSION'</exclude>|' "$BASEDIR/pom.xml"
sed_i 's|<regex>'$FROM_VERSION'\.\*</regex>|<regex>'$TO_VERSION'.*</regex>|' "$BASEDIR/pom.xml"
sed_i 's|<regex>'$FROM_VERSION'</regex>|<regex>'$TO_VERSION'</regex>|' "$BASEDIR/pom.xml"
35 changes: 29 additions & 6 deletions geomesa-sql-cli/bin/geomesa-sqlline
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ script_dir=$(dirname $script_file)
GEOMESA_SQL_HOME=$(dirname $script_dir)
GEOMESA_SQL_CONF_PATH="${GEOMESA_SQL_HOME}/conf"
GEOMESA_HOME="${GEOMESA_HOME:-$GEOMESA_SQL_HOME}"
GEOMESA_CONF_DIR="${GEOMESA_CONF_DIR:-$GEOMESA_HOME/conf}"
GEOMESA_LOG_DIR="${GEOMESA_LOG_DIR:-$GEOMESA_HOME/logs}"

# Sanity checks for GEOMESA_HOME
if [ ! -d "$GEOMESA_HOME" ]; then
Expand Down Expand Up @@ -89,14 +91,20 @@ usage() {
exit 1;
}

while getopts ":c:p:h" o; do
while getopts ":c:p:f:e:h" o; do
case "$o" in
c)
CATALOG=${OPTARG}
;;
p)
DS_PARAMS=${OPTARG}
;;
f)
INPUT_FILE=${OPTARG}
;;
e)
SQL=${OPTARG}
;;
h)
usage
esac
Expand All @@ -122,8 +130,23 @@ fi
GEOMESA_CLASSPATH=$(${GEOMESA_HOME}/bin/${GEOMESA_TOOL_NAME} classpath | tr '\n' ':')
JDBC_URL="jdbc:geomesa:${CATALOG_PROP_NAME}=${CATALOG};fun=spatial;caseSensitive=false;${DS_PARAMS}"

$RUNNER -classpath "${GEOMESA_CLASSPATH}:${GEOMESA_SQL_CONF_PATH}:${GEOMESA_SQL_CLI_JAR_PATH}" \
sqlline.SqlLine \
--verbose=true \
--connectInteractionMode=notAskCredentials \
-u "$JDBC_URL"
mkdir -p "${GEOMESA_LOG_DIR}"

ARGS=("-u" "$JDBC_URL")
if [ -n "$INPUT_FILE" ]; then
ARGS+=("-f" "$INPUT_FILE")
fi
if [ -n "$SQL" ]; then
ARGS+=("-e" "$SQL")
fi

$RUNNER \
-Dlog4j.configuration=file://${GEOMESA_CONF_DIR}/log4j.properties \
-Dgeomesa.home=${GEOMESA_HOME} \
-Dgeomesa.log.dir=${GEOMESA_LOG_DIR} \
-classpath "${GEOMESA_CLASSPATH}:${GEOMESA_SQL_CONF_PATH}:${GEOMESA_SQL_CLI_JAR_PATH}" \
sqlline.SqlLine \
--verbose=true \
--connectInteractionMode=notAskCredentials \
-u "$JDBC_URL" \
"${ARGS[@]}"
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class FilterTest extends Specification {
"ST_Contains(ST_MakeEnvelope(3, 3, 8, 8), pt)",
"ST_Crosses(ST_MakeEnvelope(3, 3, 8, 8), line)",
"ST_Overlaps(ST_MakeEnvelope(10, 10, 80, 80), poly)",
"ST_DWithin(ST_MakeEnvelope(3, 3, 8, 8), pt, 5)",
"ST_DWithin(ST_MakeEnvelope(3, 3, 8, 8), pt, 5)"
)
Result.foreach(predicates) { predicate =>
verifyGeometry(s"SELECT * FROM TEST_GEOM_DATA WHERE $predicate",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class Driver extends org.apache.calcite.jdbc.Driver {
/**
* Ensure that the driver will be registered on first instantiation of Driver object.
*/
isRegistered.synchronized {
Driver.synchronized {
if (!isRegistered) {
register()
isRegistered = true
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
<arg>-nowarn</arg>
<arg>-unchecked</arg>
<arg>-deprecation</arg>
<arg>-Xexperimental</arg>
<arg>-target:jvm-1.8</arg>
</args>
<source>1.8</source>
Expand Down

0 comments on commit 629098d

Please sign in to comment.