forked from strimzi/strimzi-kafka-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind-classpath-collision.sh
executable file
·33 lines (27 loc) · 1.28 KB
/
find-classpath-collision.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
#! /usr/bin/env bash
image=$1 #strimzi/kafka:latest-kafka-2.2.1
image_jar_dir=$2 #/opt/kafka/libs
whilelist_file=$3
DOCKER_CMD=${DOCKER_CMD:-docker}
jars_dir=`mktemp -d`
trap "[ -e $jars_dir ] && rm -rf $jars_dir" EXIT
${DOCKER_CMD} run --name temp-container-name "$image" /bin/true || exit 2
${DOCKER_CMD} cp "temp-container-name:$image_jar_dir" "$jars_dir"
${DOCKER_CMD} rm temp-container-name > /dev/null
classes_root=`mktemp -d`
trap "[ -e $classes_root ] && rm -rf $classes_root" EXIT
$(dirname $0)/extract-jars.sh "$jars_dir" "$classes_root"
collisions=$($(dirname "$0")/find-colliding-classes.sh "$classes_root" | awk '{printf("%s\t%s\n",$1,$2);}' | \
grep -vFf "$whilelist_file")
if [ "$collisions" != "" ] ; then
echo "ERROR: Different class files with same name from different jars found!"
echo "$collisions"
echo "(Ignoring jars from Kafka distribution containing different class files with same name:"
sed -e 's/^/ /' "$whilelist_file"
echo ")"
echo "It's likely that either two third party jars are using different versions "
echo "of a common (transitive) dependency or a single third party jar is using a"
echo "dependency which is also a (transitive) dependency of Kafka."
echo "In either case the solution is a judicious <exclude> of the dependency."
exit 1
fi