Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 206 lines (177 sloc) 3.93 KB
#!/bin/bash -e
HERE=`dirname ${0}`
cd "${HERE}/.."
PROJECT=`pwd`
RUN="${PROJECT}/run"
BUILDING="/tmp/build_logbuddy"
UNPACKED="${BUILDING}/unpacked"
MAIN="${PROJECT}/main"
JAVA="${MAIN}/java"
JAR="${MAIN}/jar"
SLF4J="${PROJECT}/slf4j"
SLF4J_JAVA="${SLF4J}/java"
SLF4J_JAR="${SLF4J}/jar"
########## CLEANUP ##########
rm \
--recursive \
--force \
"${BUILDING}"
mkdir \
--parents \
"${BUILDING}"
mkdir \
--parents \
"${UNPACKED}"
########## COMPILE SOURCES ##########
javac \
-classpath "${JAR}/byte-buddy-1.6.6.jar:${JAR}/objenesis-2.4.jar" \
-sourcepath "${JAVA}" \
-source 1.8 \
-target 1.8 \
-d "${UNPACKED}" \
"${JAVA}/org/logbuddy/Build.java"
########## COPY SOURCES ##########
cp \
--recursive \
"${JAVA}/." \
"${UNPACKED}"
########## COPY DEPENDENCIES ##########
unzip \
-q \
"${JAR}/byte-buddy-1.6.6.jar" \
-d "${UNPACKED}" \
net/*
unzip \
-q \
"${JAR}/objenesis-2.4.jar" \
-d "${UNPACKED}" \
org/*
########## COPY LICENSE ##########
cp \
"${RUN}"/*license* \
"${UNPACKED}"
cp \
"${PROJECT}"/LICENSE.txt \
"${UNPACKED}"
########## ZIP JAR ##########
cd "${UNPACKED}"
zip \
--quiet \
-X \
--recurse-paths \
"${BUILDING}/logbuddy.jar" \
./*
cd "${PROJECT}"
########## CLEAN UNPACKED ##########
rm \
--recursive \
--force \
"${UNPACKED}"
########## SHADE DEPENDENCIES ##########
jar tf ${BUILDING}/logbuddy.jar \
| grep "\.class$" \
| grep -v "$org/logbuddy/" \
| sed 's/\.class$//g' \
| sed 's/\//\./g' \
| xargs -I{} echo {} -\> org.logbuddy.shaded.{} : \
> "${BUILDING}/shading_map.txt"
java \
-cp "${RUN}/proguard-base-5.3.1.jar" \
proguard.ProGuard \
-injars "${BUILDING}/logbuddy.jar" \
-outjars "${BUILDING}/logbuddy-shaded.jar" \
-libraryjars "<java.home>/lib/rt.jar" \
-dontnote org.objenesis.** \
-dontwarn net.bytebuddy.** \
-dontnote net.bytebuddy.** \
-dontshrink \
-dontoptimize \
-keepattributes \* \
-keepparameternames \
-keepclassmembers class \* { \
\*\*\* \*\; \
\*\*\* \*\(...\)\; \
} \
-keep class org.logbuddy.** \
-applymapping "${BUILDING}/shading_map.txt"
mv "${BUILDING}/logbuddy-shaded.jar" "${BUILDING}/logbuddy.jar"
rm "${BUILDING}/shading_map.txt"
########## RESET TIMESTAMPS IN JAR ##########
mkdir "${UNPACKED}"
unzip \
-q \
-d "${UNPACKED}" \
"${BUILDING}/logbuddy.jar"
find "${UNPACKED}" | xargs touch --date=@0
cd "${UNPACKED}"
zip \
--quiet \
-X \
--recurse-paths \
"${BUILDING}/logbuddy.jar" \
./*
cd "${PROJECT}"
rm \
--recursive \
--force \
"${UNPACKED}"
###########################
########## SLF4J ##########
###########################
########## PREPARE ##########
mkdir \
--parents \
"${UNPACKED}"
########## COMPILE SOURCES ##########
javac \
-classpath "${SLF4J_JAR}/*:${BUILDING}/logbuddy.jar" \
-sourcepath "${SLF4J_JAVA}" \
-source 1.8 \
-target 1.8 \
-d "${UNPACKED}" \
"${SLF4J_JAVA}/org/logbuddy/bind/Slf4jBinder.java"
########## COPY SOURCES ##########
cp \
--recursive \
"${SLF4J_JAVA}/." \
"${UNPACKED}"
########## COPY LICENSE ##########
cp \
"${RUN}"/*license* \
"${UNPACKED}"
cp \
"${PROJECT}"/LICENSE.txt \
"${UNPACKED}"
########## RESET TIMESTAMPS IN UNPACKED ##########
find "${UNPACKED}" | xargs touch --date=@0
cd "${UNPACKED}"
zip \
--quiet \
-X \
--recurse-paths \
"${BUILDING}/logbuddy-slf4j.jar" \
./*
cd "${PROJECT}"
########## ZIP JAR ##########
cd "${UNPACKED}"
zip \
--quiet \
-X \
--recurse-paths \
"${BUILDING}/logbuddy-slf4j.jar" \
./*
cd "${PROJECT}"
########## CLEAN UNPACKED ##########
rm \
--recursive \
--force \
"${UNPACKED}"
######################################
########## BUILD SUCCESSFUL ##########
######################################
echo ""
echo "BUILD SUCCESSFUL"
echo "created ${BUILDING}/logbuddy.jar"
echo "sha1sum=`sha1sum ${BUILDING}/logbuddy.jar | cut -f1 -d' '`"
echo "created ${BUILDING}/logbuddy-slf4j.jar"
echo "sha1sum=`sha1sum ${BUILDING}/logbuddy-slf4j.jar | cut -f1 -d' '`"
You can’t perform that action at this time.