Skip to content

Instantly share code, notes, and snippets.

@t3rmin4t0r
Created July 26, 2013 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t3rmin4t0r/6091263 to your computer and use it in GitHub Desktop.
Save t3rmin4t0r/6091263 to your computer and use it in GitHub Desktop.
fat jar creation script. hadoop classpath | ./fatjar.sh hadoop-fat.jar
#!/bin/bash
jso_file=$1
read classpath
TMPDIR=$(mktemp -d -t classes-XXXXXX)
#echo jso: $jso_file
#echo classpath: $classpath
if [ "$CLASSPATH" == "" ]
then
CLASSPATH=./target/hadoop-jso-*.jar
fi
cp=(${classpath//:/ })
for path in "${cp[@]}"
do
if [ -f $path ]
then
extension="${path##*.}"
if [ "$extension" == "jar" ]
then
jars[$[${#jars[@]}+1]]=$path
fi
fi
done
pushd $TMPDIR;
mkdir classes;
pushd classes;
echo ${jars[@]} | xargs -P 8 -n 1 jar xf;
jar -c0f ../fat.jar .
popd;
popd;
mv -v $TMPDIR/fat.jar $jso_file
rm -r $TMPDIR
#jar -c0vf $jso_file -C classes/ .
#exec java -classpath $CLASSPATH org.apache.hadoop.jso.tool.Linker $jso_file ${jars[@]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment