-
Notifications
You must be signed in to change notification settings - Fork 0
/
converter.sh
executable file
·116 lines (84 loc) · 2.05 KB
/
converter.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# Utility script for running ModelClassConverter
# Set default arguments
ACTION="help"
BRANCH="0.1"
CONFIGURATION="configuration.xml"
DIRECTORY="converter"
EXECUTABLE="ModelClassConverter"
DOWNLOAD_ARTIFACTS="download"
# Determine which action to perform
if [ -n "$1" ]
then
ACTION=$1
fi
# Determine which branch to use
if [ -n "$2" ]
then
BRANCH=$2
fi
# Determine which configuration to use
if [ -n "$3" ]
then
CONFIGURATION=$3
fi
# Determine whether to download the artifacts
if [ -n "$4" ]
then
DOWNLOAD_ARTIFACTS=$4
fi
echo "converter.sh"
printf "\tAction: %s\n", "$ACTION"
printf "\tBranch: %s\n", "$BRANCH"
# Run different actions
if [ "$ACTION" == "help" ]
then
echo "Usage:"
echo "./converter.sh [help|run|clean] [branch] [configuration] [download]"
echo ""
elif [ "$ACTION" == "clean" ]
then
rm -Rf "$DIRECTORY"
echo "Cleaned"
elif [ "$ACTION" == "run" ]
then
if [ ! -f "$CONFIGURATION" ]
then
echo "Could not find configuration at location: $CONFIGURATION"
exit
fi
if [ ! -d "$DIRECTORY" ]
then
git clone git@github.com:topicusonderwijs/ModelClassConverter.git "$DIRECTORY"
else
echo "Already cloned repository"
fi
cd "$DIRECTORY"
git checkout "$BRANCH"
EXECUTABLE="$EXECUTABLE-$BRANCH"
if [ ! -f "target/$EXECUTABLE.jar" ]
then
mvn clean compile assembly:single -U
cd target
pwd
mv ModelClassConverter*jar "$EXECUTABLE.jar"
cd ..
else
echo "Already compiled executable"
fi
cd ..
# Download artifacts
# This functionality should be moved into the generator itself.
if [ "$DOWNLOAD_ARTIFACTS" == "download" ]
then
# Determine artifacts
DEPENDENCIES=$(perl -e 'while ($_ = <>) { /<dependency name=\"(.*?)\"/; if ( $t ne $1 ) { print "$1\n"; $t = $1; } }' < "$CONFIGURATION")
# Download artifacts
for DEPENDENCY in $DEPENDENCIES
do
mvn org.apache.maven.plugins:maven-dependency-plugin:get -Dartifact="$DEPENDENCY"
done
fi
# Run generator
java -cp "$DIRECTORY/target/$EXECUTABLE.jar" mcconverter.main.Main --formatted --configuration "$CONFIGURATION"
fi