-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_duplicates
executable file
·38 lines (28 loc) · 1.11 KB
/
check_duplicates
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
#!/bin/bash
# Script that will check for dependencies declared multiple times in the same pom.xml
bold=$(tput bold)
normal=$(tput sgr0)
rm -f dependencies_duplicates.csv
echo "Searching dependencies..."
mvn dependency:analyze-duplicate | #analyze if there are duplicates
grep ") @ \|[[:blank:]]o " | # remove unimportant info
sed 's/^.*\(@.*\).*---/\1/' | # search for the component name
sed -e 's/[[:blank:]]\{1,\}o//' | # remove blank spaces
sed -Ee 's/\[INFO\] / /' | # remove INFO
sed 's/:/,/g' | # replace : with ,
tee dependencies_duplicates # print to console and file
echo -e "\nDependencies list created!"
echo 'groupId,artifactId,type,component' > dependencies_duplicates.csv
component=1;
while read p; do
if [ ${p:0:1} == '@' ]; then
component=$p
echo "Analyzing component $component"
elif [ ${p:0:1} != '[' ]; then
echo "Found duplicate $p"
echo "$p,$component" >> dependencies_duplicates.csv
fi
done < dependencies_duplicates
echo -e "\nFinish creating duplicates list!"
rm -f dependencies_duplicates
echo -e "\nDONE! Please check ${bold}dependencies_duplicates.csv"