about summary refs log tree commit diff stats
path: root/home-manager/packages/scripts/deprecated/java_compiler/no-pack/jj-no-pack
blob: d476ce52eb36730f8ffa356ef3d5dd49f647c76c (plain) (blame)
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
#! /usr/bin/env dash
# shellcheck disable=SC2086
. ./lib

help() {
cat << EOF 
Add all dirs with trailing /

\$1 = java .class files dir
\$2 = java .jar files dir

if you want to update libs delete this:
"$wd"/libs.cache

EOF
exit 0
}


class=$(mktemp)
jar=$(mktemp)
pwd=$(pwd)

mkdir "$pwd"/out/cache 2> /dev/null
wd="$pwd"/out/cache
[ "$1" = "-h" ] && help 
[ "$1" = "--help" ] && help 

[ -z "$1" ] && echo "no args" && help && exit 1
[ -z "$2" ] && echo "no args" && help && exit 1

while IFS= read -r i;do
    cp "$i" $wd/"$(basename $i)"
done < "$(tmp "find $1 | sed 1d" )"

while IFS= read -r i;do
    if ! grep "^$i$" "$wd"/libs.cache;then
        echo "$i" | sed "s|$2||" >> "$wd"/libs.cache
        cd $wd
        jar -xf "$pwd"/"$i"
        cd $pwd
    fi
done < "$(tmp "find $2 | sed 1d" )"

while IFS= read -r a;do
    echo "$a" | sed "s|$wd/||" >> $jar
done < "$(tmp "find $wd | sed 1d")"



cd "$wd" || die "No $wd"
jar -c -f myJar.jar -e Main $(cat $jar | tr '\n' ' ') 

mv myJar.jar "$pwd"/out/myJar.jar

rm $jar
rm $class