-
Notifications
You must be signed in to change notification settings - Fork 0
/
refactor_mycode_gradle.sh
executable file
·82 lines (51 loc) · 2.26 KB
/
refactor_mycode_gradle.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
#!/bin/bash
prompt () {
if [ -z "$NO_PROMPT" ]; then
echo $'\n\n\n'
read -p "$1. Press enter to continue:"
fi
}
gradle clean
########################################################################
# Define variables
########################################################################
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 "========================="
gradle clean test jar
echo "=================================================="
echo "Adding the scalafix dependency to the project"
echo "=================================================="
cp build.gradle build.gradle.bak
cp gradle.properties gradle.properties.bak
cp settings.gradle settings.gradle.bak
cat build.gradle.bak | \
python update_gradle_build.py > build.gradle
#Copy scalafix
cp .scalafix.conf.sample .scalafix.conf
echo "=================================================="
prompt "Setup for scalafix complete"
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 "=================================================="
gradle scalafix #|| (echo "Linter warnings were found"; prompt)
cp .scalafix-warn.conf.sample .scalafix.conf
gradle scalafix || (echo "Linter warnings were found"; prompt)
echo "=================================================="
echo "ScalaFix is COMPLETED, Review the Changes now (e.g. git diff)"
echo "=================================================="
prompt "Scalafix run complete"
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 "Build file setup done. Next, we will build a jar"
gradle jar
prompt "Jar has been built. Check build/libs for the jar"