| 
1 | 1 | #!/bin/bash  | 
 | 2 | +# Licensed to the Apache Software Foundation (ASF) under one  | 
 | 3 | +# or more contributor license agreements.  See the NOTICE file  | 
 | 4 | +# distributed with this work for additional information  | 
 | 5 | +# regarding copyright ownership.  The ASF licenses this file  | 
 | 6 | +# to you under the Apache License, Version 2.0 (the  | 
 | 7 | +# "License"); you may not use this file except in compliance  | 
 | 8 | +# with the License.  You may obtain a copy of the License at  | 
2 | 9 | #  | 
3 |  | -# Licensed to the Apache Software Foundation (ASF) under one or more  | 
4 |  | -# contributor license agreements.  See the NOTICE file distributed with  | 
5 |  | -# this work for additional information regarding copyright ownership.  | 
6 |  | -# The ASF licenses this file to You under the Apache License, Version 2.0  | 
7 |  | -# (the "License"); you may not use this file except in compliance with  | 
8 |  | -# the License.  You may obtain a copy of the License at  | 
 | 10 | +#   http://www.apache.org/licenses/LICENSE-2.0  | 
9 | 11 | #  | 
10 |  | -#    http://www.apache.org/licenses/LICENSE-2.0  | 
11 |  | -#  | 
12 |  | -# Unless required by applicable law or agreed to in writing, software  | 
13 |  | -# distributed under the License is distributed on an "AS IS" BASIS,  | 
14 |  | -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  | 
15 |  | -# See the License for the specific language governing permissions and  | 
16 |  | -# limitations under the License.  | 
17 |  | -#  | 
18 |  | - | 
19 |  | -SPARK_VERSION=$1  | 
20 |  | -SEDONA_VERSION=$2  | 
21 |  | -BUILD_MODE=$3  | 
22 |  | -GEOTOOLS_VERSION=${4:-auto}  | 
23 |  | - | 
24 |  | -SEDONA_SPARK_VERSION=${SPARK_VERSION:0:3}  | 
25 |  | -if [ "${SPARK_VERSION:0:1}" -eq "3" ] && [ "${SPARK_VERSION:2:1}" -le "3" ]; then  | 
26 |  | -    # 3.0, 3.1, 3.2, 3.3  | 
27 |  | -    SEDONA_SPARK_VERSION=3.0  | 
28 |  | -fi  | 
29 |  | - | 
30 |  | -# Function to compare two version numbers  | 
31 |  | -version_gt() {  | 
32 |  | -  # Compare two version numbers  | 
33 |  | -  # Returns 0 if the first version is greater, 1 otherwise  | 
34 |  | -  [ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" ]  | 
35 |  | -}  | 
36 |  | - | 
37 |  | -# Function to get the latest version of a Maven package  | 
38 |  | -get_latest_version_with_suffix() {  | 
39 |  | -  BASE_URL=$1  | 
40 |  | -  SUFFIX=$2  | 
41 |  | - | 
42 |  | -  # Fetch the maven-metadata.xml file  | 
43 |  | -  METADATA_URL="${BASE_URL}maven-metadata.xml"  | 
44 |  | -  METADATA_XML=$(curl -s "$METADATA_URL")  | 
45 |  | - | 
46 |  | -  # Extract versions from the XML  | 
47 |  | -  VERSIONS=$(echo "$METADATA_XML" | grep -o '<version>[^<]*</version>' | awk -F'[<>]' '{print $3}')  | 
48 |  | - | 
49 |  | -  LATEST_VERSION=""  | 
50 |  | - | 
51 |  | -  # Filter versions that end with the specified suffix and find the largest one  | 
52 |  | -  for VERSION in $VERSIONS; do  | 
53 |  | -    if [[ $VERSION == *$SUFFIX ]]; then  | 
54 |  | -      if [[ -z $LATEST_VERSION ]] || version_gt "$VERSION" "$LATEST_VERSION"; then  | 
55 |  | -        LATEST_VERSION=$VERSION  | 
56 |  | -      fi  | 
57 |  | -    fi  | 
58 |  | -  done  | 
59 |  | - | 
60 |  | -  if [[ -z $LATEST_VERSION ]]; then  | 
61 |  | -    exit 1  | 
62 |  | -  else  | 
63 |  | -    echo "$LATEST_VERSION"  | 
64 |  | -  fi  | 
65 |  | -}  | 
66 |  | - | 
67 |  | -if [ "$GEOTOOLS_VERSION" = "auto" ]; then  | 
68 |  | -    GEOTOOLS_VERSION=$(mvn help:evaluate -Dexpression=geotools.version -q -DforceStdout)  | 
69 |  | -    echo "GeoTools version inferred from pom.xml: $GEOTOOLS_VERSION"  | 
70 |  | -fi  | 
71 |  | - | 
72 |  | -GEOTOOLS_WRAPPER_VERSION="${SEDONA_VERSION}-${GEOTOOLS_VERSION}"  | 
73 |  | -if [ "$SEDONA_VERSION" = "latest" ]; then  | 
74 |  | -    GEOTOOLS_WRAPPER_VERSION=$(get_latest_version_with_suffix "https://repo1.maven.org/maven2/org/datasyslab/geotools-wrapper/" "$GEOTOOLS_VERSION")  | 
75 |  | -    if [ -z "$GEOTOOLS_WRAPPER_VERSION" ]; then  | 
76 |  | -        echo "No geotools-wrapper version with suffix $GEOTOOLS_VERSION"  | 
77 |  | -        exit 1  | 
78 |  | -    fi  | 
79 |  | -    echo "Using latest geotools-wrapper version: $GEOTOOLS_WRAPPER_VERSION"  | 
80 |  | - | 
81 |  | -    # The compilation must take place outside Docker to avoid unnecessary maven packages  | 
82 |  | -    mvn clean install -DskipTests -Dspark="${SEDONA_SPARK_VERSION}" -Dscala=2.12  | 
83 |  | -fi  | 
84 |  | - | 
85 |  | -# -- Building the image  | 
86 |  | - | 
87 |  | -if [ -z "$BUILD_MODE" ] || [ "$BUILD_MODE" = "local" ]; then  | 
88 |  | -    # If local, build the image for the local environment  | 
89 |  | -    docker buildx build --load \  | 
90 |  | -    --build-arg spark_version="${SPARK_VERSION}" \  | 
91 |  | -    --build-arg sedona_version="${SEDONA_VERSION}" \  | 
92 |  | -    --build-arg geotools_wrapper_version="${GEOTOOLS_WRAPPER_VERSION}" \  | 
93 |  | -    -f docker/sedona-docker.dockerfile \  | 
94 |  | -    -t apache/sedona:"${SEDONA_VERSION}" .  | 
95 |  | -else  | 
96 |  | -    # If release, build the image for cross-platform  | 
97 |  | -    docker buildx build --platform linux/amd64,linux/arm64 \  | 
98 |  | -    --progress=plain \  | 
99 |  | -    --no-cache \  | 
100 |  | -    --output type=registry \  | 
101 |  | -    --build-arg spark_version="${SPARK_VERSION}" \  | 
102 |  | -    --build-arg sedona_version="${SEDONA_VERSION}" \  | 
103 |  | -    --build-arg geotools_wrapper_version="${GEOTOOLS_WRAPPER_VERSION}" \  | 
104 |  | -    -f docker/sedona-docker.dockerfile \  | 
105 |  | -    -t apache/sedona:"${SEDONA_VERSION}" .  | 
106 |  | -fi  | 
 | 12 | +# Unless required by applicable law or agreed to in writing,  | 
 | 13 | +# software distributed under the License is distributed on an  | 
 | 14 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY  | 
 | 15 | +# KIND, either express or implied.  See the License for the  | 
 | 16 | +# specific language governing permissions and limitations  | 
 | 17 | +# under the License.  | 
0 commit comments