2020-01-20 20:39:38 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2020-01-20 20:49:35 +00:00
|
|
|
if [ $# -gt 0 -a "$1" = "-v" ]
|
|
|
|
then
|
|
|
|
RETROFLAG="false"
|
|
|
|
JARFLAG="v"
|
|
|
|
shift
|
|
|
|
set -x
|
|
|
|
fi
|
2020-01-20 20:39:38 +00:00
|
|
|
|
|
|
|
if [ $# -ne 1 ]
|
|
|
|
then
|
|
|
|
echo Provide on jar file to convert on the command line.
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
REALPATH=$(realpath $0)
|
|
|
|
BIN_DIR=`dirname "$REALPATH"`
|
|
|
|
LIB_DIR=$BIN_DIR
|
|
|
|
|
|
|
|
JAR_TO_CONVERT="$1"
|
|
|
|
INPUT_DIR="$JAR_TO_CONVERT".inputdir
|
|
|
|
OUTPUT_DIR="$JAR_TO_CONVERT".outputdir
|
|
|
|
|
|
|
|
rm -rf "$INPUT_DIR"
|
|
|
|
rm -rf "$OUTPUT_DIR"
|
|
|
|
mkdir "$INPUT_DIR"
|
|
|
|
mkdir "$OUTPUT_DIR"
|
2020-01-20 20:49:35 +00:00
|
|
|
(cd "$INPUT_DIR"; jar -x${JARFLAG}f $OLDPWD/"$JAR_TO_CONVERT")
|
2020-01-20 20:39:38 +00:00
|
|
|
|
2020-01-20 20:49:35 +00:00
|
|
|
echo "Converting..."
|
2020-01-20 20:39:38 +00:00
|
|
|
java \
|
|
|
|
-Dretrolambda.bytecodeVersion=49 \
|
|
|
|
-Dretrolambda.defaultMethods=true \
|
|
|
|
-Dretrolambda.inputDir="$INPUT_DIR" \
|
|
|
|
-Dretrolambda.outputDir="$OUTPUT_DIR" \
|
|
|
|
-Dretrolambda.classpath="$JAR_TO_CONVERT" \
|
|
|
|
-Dretrolambda.javacHacks=true \
|
2020-01-20 20:49:35 +00:00
|
|
|
-Dretrolambda.quiet=${RETROFLAG:-true} \
|
2020-01-20 20:39:38 +00:00
|
|
|
-jar "$LIB_DIR"/retrolambda-2.5.6.jar
|
|
|
|
|
|
|
|
# The order of the "m" and "f" must match the order that the
|
|
|
|
# corresponding files appear in the argument list. This is
|
|
|
|
# so stupid...
|
2020-01-20 20:49:35 +00:00
|
|
|
NEW_JAR_NAME="${JAR_TO_CONVERT%.jar}-java5.jar"
|
|
|
|
echo "Repackaging to ${NEW_JAR_NAME}"
|
|
|
|
jar -c${JARFLAG}fm "${NEW_JAR_NAME}" \
|
2020-01-20 20:39:38 +00:00
|
|
|
"$OUTPUT_DIR"/META-INF/MANIFEST.MF \
|
|
|
|
-C "$OUTPUT_DIR" .
|