-
Notifications
You must be signed in to change notification settings - Fork 0
/
retrolambda.sh
executable file
·34 lines (26 loc) · 1.16 KB
/
retrolambda.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
retrolambda_jar=$1
android_classpath=$2
in_dir=$3
out_dir=$4
# loop through all the jars within in_dir and run retrolambda on them all
for old_jar in $(find -L $in_dir -name *.jar); do
# extract the old jar to get at our classes
classes_dir=$old_jar.classes
unzip $old_jar -d $classes_dir
# run retrolambda on its classes
java -Dretrolambda.inputDir=$classes_dir -Dretrolambda.classpath=$old_jar:$android_classpath -javaagent:$retrolambda_jar -jar $retrolambda_jar
# map our jar path from our in dir to our out dir
new_jar=${old_jar//$in_dir/$out_dir}
mkdir -p `dirname $new_jar`
# archive up our processed classes
jar -cf $new_jar -C $classes_dir .
done
# loop through all the linked directories in our bin dir
for link in $(find $in_dir/buck-out/bin -type l); do
# we expect each link to be a directory containing class files
inpath=`readlink $link`
outpath=${link//$in_dir/$out_dir}
# run retrolambda on the classes
java -Dretrolambda.inputDir=$inpath -Dretrolambda.outputDir=$outpath -Dretrolambda.classpath=$classdir:$android_classpath -javaagent:$retrolambda_jar -jar $retrolambda_jar
done