forked from tuhh-softsec/vul4j
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompress_deps
44 lines (35 loc) · 1.45 KB
/
compress_deps
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
#!/bin/bash
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
benchmark_name=$(echo $script_dir | rev | cut -d "/" -f 3 | rev)
project_name=$(echo $script_dir | rev | cut -d "/" -f 2 | rev)
bug_id=$(echo $script_dir | rev | cut -d "/" -f 1 | rev)
dir_name=/experiment/$benchmark_name/$project_name/$bug_id
TARGET_PATH=$1
DEPENDENCY_PATH=$TARGET_PATH/dependency
EXTRACTED_DEPENDENCIES_PATH=$TARGET_PATH/extracted_dependencies
MODULE="$(basename "$(dirname "$TARGET_PATH")")"
if [ "$MODULE" != "src" ]; then
MODULE="src/$MODULE"
fi
ALL_DEPS_JAR=$dir_name/$MODULE/all-dependencies.jar
cd $dir_name/src;
mvn dependency:copy-dependencies
rm -rf "$EXTRACTED_DEPENDENCIES_PATH" \
&& mkdir "$EXTRACTED_DEPENDENCIES_PATH" \
&& cd "$EXTRACTED_DEPENDENCIES_PATH" \
&& echo "Remove junit*.jar files from $DEPENDENCY_PATH ..." \
&& find "$DEPENDENCY_PATH" -type f -name "junit*.jar" -delete \
&& echo "Extract all dependencies from the 'jar' files from $DEPENDENCY_PATH ..." \
&& find "$DEPENDENCY_PATH" -type f -name "*.jar" -exec jar -xf {} \;
echo "Delete *.RSA *.DSA *.SF signature files..." \
&& find . -type f \( -name "*.RSA" -o -name "*.DSA" -o -name "*.SF" \) -delete
echo "Merge all dependencies into a single 'jar' file..." \
&& jar -cf $ALL_DEPS_JAR -C . .
count_compressed_classes=$(unzip -l $ALL_DEPS_JAR | grep \.class | wc -l)
if [[ $count_compressed_classes -ne 0 ]]
then
echo "SUCCESS"
else
echo "Empty jar"
fi;
exit 0