Skip to content

Commit

Permalink
Clean up css and bash scripts (#2972)
Browse files Browse the repository at this point in the history
  • Loading branch information
elahrvivaz committed Jul 31, 2023
1 parent 0639a24 commit d777de3
Show file tree
Hide file tree
Showing 34 changed files with 384 additions and 983 deletions.
9 changes: 5 additions & 4 deletions build/bloop-export.sh
@@ -1,11 +1,12 @@
#!/usr/bin/env bash

mvn -Pbloop ch.epfl.scala:bloop-maven-plugin:2.0.0:bloopInstall
if [[ $? -eq 0 ]]; then
if [[ -f .bloop/geomesa-utils_2.12.json && -z "$(grep 'src/main/scala_2.12' .bloop/geomesa-utils_2.12.json)" ]]; then
cd "$(dirname "$0")/.." || exit

if mvn -Pbloop ch.epfl.scala:bloop-maven-plugin:2.0.0:bloopInstall; then
if [[ -f .bloop/geomesa-utils_2.12.json ]] && ! grep -q 'src/main/scala_2.12' .bloop/geomesa-utils_2.12.json; then
sed -i 's|\(.*/geomesa-utils/src/main/scala\)"|\0,\n\1\_2.12"|' .bloop/geomesa-utils_2.12.json
fi
if [[ -f .bloop/geomesa-utils_2.13.json && -z "$(grep 'src/main/scala_2.13' .bloop/geomesa-utils_2.13.json)" ]]; then
if [[ -f .bloop/geomesa-utils_2.13.json ]] && ! grep -q 'src/main/scala_2.13' .bloop/geomesa-utils_2.13.json; then
sed -i 's|\(.*/geomesa-utils/src/main/scala\)"|\0,\n\1\_2.13"|' .bloop/geomesa-utils_2.13.json
fi
fi
13 changes: 6 additions & 7 deletions build/calculate-cqs.sh
Expand Up @@ -13,19 +13,18 @@ mvn dependency:tree -Dstyle.color=never > build/deps-raw
grep ':compile' build/deps-raw | grep -v 'omitted' | grep -v 'org.locationtech.geomesa' | sed -e 's/\[INFO\] //' -e 's/[\| +-]*//' -e 's/(.*)//' -e 's/ //g' -e 's/\(.*\):\(.*\):jar:\(.*\):\(\w*\)/\1:\2\t\3\t\4/' | sort | uniq > build/cqs.tsv
echo "" >> build/cqs.tsv
for cq in $(grep ':provided' build/deps-raw | grep '^\[INFO\] +-' | grep -v 'org.locationtech.geomesa' | sed -e 's/\[INFO\] +- //' -e 's/(.*)//' | sort | uniq); do
dep="$(echo $cq | sed 's/\(.*\):\(.*\):jar:\(.*\):\(\w*\)/\1:\2\t\3\t\4/')"
reg=$(echo "${dep% *}" | sed 's/\s\s*/\\s*/g')
if [ -z "$(grep $reg build/cqs.tsv)" ]; then
dep="$(echo "$cq" | sed -E 's/(.*):(.*):jar:(.*):(\w*)/\1:\2\t\3\t\4/')"
reg=$(echo "${dep% *}" | sed -E 's/\s\s*/\\s*/g')
if ! grep -q "$reg" build/cqs.tsv; then
echo "$dep" >> build/cqs.tsv
fi
done
echo "" >> build/cqs.tsv
for cq in $(grep ':test' build/deps-raw | grep '^\[INFO\] +-' | grep -v 'org.locationtech.geomesa' | sed -e 's/\[INFO\] +- //' -e 's/(.*)//' | sort | uniq); do
dep="$(echo $cq | sed 's/\(.*\):\(.*\):jar:\(.*\):\(\w*\)/\1:\2\t\3\t\4/')"
reg=$(echo "${dep% *}" | sed 's/\s\s*/\\s*/g')
if [ -z "$(grep $reg build/cqs.tsv)" ]; then
dep="$(echo "$cq" | sed -E 's/(.*):(.*):jar:(.*):(\w*)/\1:\2\t\3\t\4/')"
reg=$(echo "${dep% *}" | sed -E 's/\s\s*/\\s*/g')
if ! grep -q "$reg" build/cqs.tsv; then
echo "$dep" >> build/cqs.tsv
fi
done
rm build/deps-raw

26 changes: 10 additions & 16 deletions build/change-scala-version.sh
Expand Up @@ -23,7 +23,7 @@ VALID_VERSIONS=("2.12" "2.13")
FULL_VERSIONS=("2.12.17" "2.13.10")

usage() {
echo "Usage: $(basename $0) [-h|--help] <version>
echo "Usage: $(basename "$0") [-h|--help] <version>
where :
-h| --help Display this help text
valid version values : ${VALID_VERSIONS[*]}
Expand All @@ -35,12 +35,12 @@ if [[ ($# -ne 1) || ( $1 == "--help") || $1 == "-h" ]]; then
usage
fi

BASEDIR=$(dirname $0)/..
BASEDIR=$(dirname "$0")/..
TO_VERSION=$1
FULL_VERSION=""

for i in "${!VALID_VERSIONS[@]}"; do
if [[ $TO_VERSION == ${VALID_VERSIONS[$i]} ]]; then
if [[ $TO_VERSION == "${VALID_VERSIONS[$i]}" ]]; then
FULL_VERSION="${FULL_VERSIONS[$i]}"
fi
done
Expand All @@ -51,27 +51,21 @@ if [[ -z "$FULL_VERSION" ]]; then
fi

# pull out the scala version from the main artifactId
FROM_VERSION="$(sed -n '/geomesa_/ s| *<artifactId>geomesa_\([0-9]\.[0-9][0-9]*\)</artifactId>|\1|p' $BASEDIR/pom.xml)"

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

export -f sed_i
FROM_VERSION="$(sed -n '/geomesa_/ s| *<artifactId>geomesa_\([0-9]\.[0-9][0-9]*\)</artifactId>|\1|p' "$BASEDIR"/pom.xml)"

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

# 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][0-9]*</s/<scala\.binary\.version>[0-9]\.[0-9][0-9]*</<scala.binary.version>'$TO_VERSION'</' \
sed -i "1,/<scala\.binary\.version>[0-9]\.[0-9][0-9]*</s/<scala\.binary\.version>[0-9]\.[0-9][0-9]*</<scala.binary.version>$TO_VERSION</" \
"$BASEDIR/pom.xml"

# update <scala.version> in parent POM
sed_i '1,/<scala\.version>[0-9]\.[0-9][0-9]*\.[0-9][0-9]*</s/<scala\.version>[0-9]\.[0-9][0-9]*\.[0-9][0-9]*</<scala.version>'$FULL_VERSION'</' \
sed -i "1,/<scala\.version>[0-9]\.[0-9][0-9]*\.[0-9][0-9]*</s/<scala\.version>[0-9]\.[0-9][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"
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"
Expand Up @@ -2,15 +2,15 @@

to="$(date +%Y)"
from="$((to - 1))"
dir="$(cd "`dirname "$0"`/../.."; pwd)"
dir="$(cd "$(dirname "$0")/.." || exit; pwd)"

sed -i "s|<copyright.year>$from</copyright.year>|<copyright.year>$to</copyright.year>|" pom.xml
sed -i "s|<copyright.year>$from</copyright.year>|<copyright.year>$to</copyright.year>|" "$dir/pom.xml"

for file in $(find . -name '*.scala') $(find . -name '*.java'); do
for file in $(find "$dir" -name '*.scala') $(find "$dir" -name '*.java'); do
sed -i \
-e "s/Copyright (c) 2013-$from Commonwealth Computer Research, Inc\./Copyright (c) 2013-$to Commonwealth Computer Research, Inc./" \
-e "s/Copyright (c) 2016-$from Dstl/Copyright (c) 2016-$to Dstl/" \
-e "s/Copyright (c) 2017-$from IBM/Copyright (c) 2017-$to IBM/" \
-e "s/Copyright (c) 2019-$from The MITRE Corporation/Copyright (c) 2019-$to The MITRE Corporation/" \
$file
"$file"
done

0 comments on commit d777de3

Please sign in to comment.