-
Notifications
You must be signed in to change notification settings - Fork 0
/
refactor_mycode.sh
executable file
·92 lines (60 loc) · 2.67 KB
/
refactor_mycode.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
prompt () {
if [ -z "$NO_PROMPT" ]; then
read -p "Press enter to continue:"
fi
}
########################################################################
# Setting variables for your Upgrade
########################################################################
INITIAL_VERSION=${INITIAL_VERSION:-2.4.8}
TARGET_VERSION=${TARGET_VERSION:-3.3.1}
SCALAFIX_RULES_VERSION=${SCALAFIX_RULES_VERSION:-0.1.9}
########################################################################
# Run scalafix
########################################################################
echo "========================="
echo "Building current project"
echo "========================="
sbt clean compile test package
echo "=================================================="
echo "Adding the scalafix dependency to the project"
echo "=================================================="
cp -af build.sbt build.sbt.bak
cat >> build.sbt <<- EOM
scalafixDependencies in ThisBuild +=
"com.holdenkarau" %% "spark-scalafix-rules-${INITIAL_VERSION}" % "${SCALAFIX_RULES_VERSION}"
semanticdbEnabled in ThisBuild := true
EOM
mkdir -p project
cat >> project/plugins.sbt <<- EOM
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.10.4")
EOM
cp .scalafix.conf.sample .scalafix.conf
echo "=================================================="
prompt
echo "=================================================="
echo "Now we'll try and run the scalafix rules in your project!"
echo "This might FAIL if you have interesting build targets."
echo "=================================================="
sbt scalafix
echo "=================================================="
echo "Now we'll be running the scalafix warning check..."
echo "=================================================="
cp .scalafix-warn.conf.sample .scalafix.conf
sbt scalafix || (echo "Linter warnings were found"; prompt)
echo "=================================================="
echo "ScalaFix is COMPLETED, Review the Changes now (e.g. git diff)"
echo "=================================================="
prompt
# We don't run compile test because some changes are not back compat (see value/key change).
# sbt clean compile test package
cp -af build.sbt build.sbt.bak.pre3
cat build.sbt.bak.pre3 | \
python -c "import re,sys;print(sys.stdin.read().replace(\"${INITIAL_VERSION}\", \"${TARGET_VERSION}\"))" > build.sbt
echo "=================================================="
echo "You will also need to update dependency versions now (e.g. Spark to 3.3 and libs)"
echo "Please address those and then press ENTER to build new $TARGET_VERSION version"
echo "=================================================="
prompt
sbt clean compile test package