You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

createPluginJar.sh 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. # This script will create a plugin jar file for a given plugin.
  3. if [ "${1}" = "" -o "${2}" = "" ]; then
  4. echo "Usage Example: ${0} com.dmdirc.addons.windowstatus WindowStatusPlugin"
  5. echo "The above would create WindowStatusPlugin.jar in the plugins/ folder of the current dir"
  6. exit;
  7. fi
  8. srcdir=${PWD}
  9. pluginname=${1}
  10. foldername=${pluginname//.//}
  11. newer=`find src/${foldername} -type f -newer ${srcdir}/plugins/${2}.jar 2>&1 | wc -l`
  12. if [ $newer -eq 0 ]; then
  13. echo "${2}.jar appears to be up-to-date";
  14. exit 0;
  15. fi
  16. echo "Creating ${2}.jar for ${pluginname} (${foldername})"
  17. if [ ! -e src/${foldername}/plugin.config ]; then
  18. echo "no plugin.config found";
  19. exit 0;
  20. fi
  21. #echo "looking for classes"
  22. TMPDIR=`mktemp -d`
  23. #echo "Using temp dir: ${TMPDIR}"
  24. cd $TMPDIR
  25. mkdir META-INF
  26. if [ -e ${srcdir}/src/${foldername}/plugin.config ]; then
  27. cp ${srcdir}/src/${foldername}/plugin.config META-INF/
  28. fi;
  29. # Do the same for plugin.config
  30. # This is rudimentary, it a version: section already exists (eg to specify
  31. # friendlyversion) then it won't add the number= key.
  32. if [ -e META-INF/plugin.config ]; then
  33. VERSIONLINE=`grep -n "version:$" META-INF/plugin.config | cut -f 1 -d ':'`
  34. if [ -z "$VERSIONLINE" ]; then
  35. sed 's/keysections:/keysections:\n version/g' META-INF/plugin.config > META-INF/plugin.config.temp
  36. rm -Rf META-INF/plugin.config
  37. mv META-INF/plugin.config.temp META-INF/plugin.config
  38. fi;
  39. SVN=`which svn`
  40. SVNREV=`$SVN info $srcdir/src/$foldername 2>&1 | grep "Last Changed Rev"`
  41. SVNREV=${SVNREV##*: }
  42. echo "" >> META-INF/plugin.config
  43. echo "" >> META-INF/plugin.config
  44. echo "version:" >> META-INF/plugin.config;
  45. if [ -n "$SVNREV" ]; then
  46. echo " number=$SVNREV" >> META-INF/plugin.config;
  47. else
  48. echo " number=0" >> META-INF/plugin.config;
  49. fi;
  50. fi;
  51. foo=`echo $foldername | sed -e 's/\/[^\/]*$//g'`
  52. mkdir -p $foo
  53. cd ${foo}
  54. ln -s ${srcdir}/build/classes/${foldername} .
  55. cd $TMPDIR
  56. mkdir -p ${srcdir}/plugins/
  57. if [ -d ${srcdir}/build/classes -a ! -e ${srcdir}/build/classes/plugins ]; then
  58. ln -s ${srcdir}/plugins ${srcdir}/build/classes/plugins;
  59. fi
  60. rm -Rf ${srcdir}/plugins/${2}.jar
  61. jar -cvf ${srcdir}/src/${foldername}/${2}.jar META-INF >/dev/null
  62. bit=""
  63. while [ 1 -eq 1 ]; do
  64. bit=${bit}/*
  65. ls ${foo}${bit}/* >/dev/null 2>&1
  66. if [ ${?} -ne 0 ]; then
  67. break;
  68. else
  69. DIR=${PWD}
  70. for prepackage in `ls ${srcdir}/src/${foldername}${bit}/prePackage.sh 2>/dev/null`; do
  71. cd `dirname ${prepackage}`
  72. /bin/sh ${prepackage}
  73. cd ${DIR}
  74. done;
  75. jar -uvf ${srcdir}/src/${foldername}/${2}.jar `ls -1 ${foo}${bit}/*.class ${foo}${bit}/*.png ${foo}${bit}/*.exe ${foo}${bit}/*.dll 2>/dev/null` >/dev/null
  76. fi
  77. done
  78. mv ${srcdir}/src/${foldername}/${2}.jar ${srcdir}/plugins/
  79. cd ${srcdir}
  80. rm -Rf ${TMPDIR}
  81. #echo "done";