#! /bin/bash
# 0 define target jar file name
targetjarName="test.jar"
# 1. find classpath
curPath=$(cd "$(dirname "$0")"; pwd)
# echo $curPath
stormHome='/usr/local/storm'
for i in $stormHome/lib/*.jar;do
classpath="$i:$classpath"
done;
# echo $classpath
# 2. find java files
for f in `find ./src -name "*.java"`;do
files="$f $files"
done
echo $files
# 3. complie java files
javac -d ./bin -cp $classpath $files
# 4. find class files
for f in `cd ./bin&&find . -name "*.class"`;do
classfiles="$f $classfiles"
done
# 5. package class files to jar
cd ./bin && jar -cvf $curPath/$targetjarName $classfiles
# 6. find resource files
for f in `cd $curPath/resources && find . -name "*"`;do
resfiles="$f $resfiles"
done
# 7. add resources to jar
cd $curPath/resources && jar -uf $curPath/$targetjarName $resfiles