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.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. destdir=${PWD}
  9. srcdir=${PWD}/modules/plugins/
  10. pluginname=${1}
  11. foldername=${pluginname//.//}
  12. newer=`find ${srcdir}/src/${foldername} -type f -newer ${destdir}/plugins/${2}.jar 2>&1 | wc -l`
  13. if [ $newer -eq 0 ]; then
  14. echo "${2}.jar appears to be up-to-date";
  15. exit 0;
  16. fi
  17. echo "Creating ${2}.jar for ${pluginname} (${foldername})"
  18. if [ ! -e modules/plugins/src/${foldername}/plugin.config ]; then
  19. echo "no plugin.config found";
  20. exit 0;
  21. fi
  22. #echo "looking for classes"
  23. TMPDIR=`mktemp -d`
  24. #echo "Using temp dir: ${TMPDIR}"
  25. cd $TMPDIR
  26. mkdir META-INF
  27. if [ -e "${srcdir}/src/${foldername}/plugin.config" ]; then
  28. cp "${srcdir}/src/${foldername}/plugin.config" META-INF/
  29. fi;
  30. # Do the same for plugin.config
  31. # This is rudimentary, it a version: section already exists (eg to specify
  32. # friendlyversion) then it won't add the number= key.
  33. if [ -e META-INF/plugin.config ]; then
  34. VERSIONLINE=`grep -n "version:$" META-INF/plugin.config | cut -f 1 -d ':'`
  35. if [ -z "$VERSIONLINE" ]; then
  36. sed 's/keysections:/keysections:\n version/g' META-INF/plugin.config > META-INF/plugin.config.temp
  37. rm -Rf META-INF/plugin.config
  38. mv META-INF/plugin.config.temp META-INF/plugin.config
  39. fi;
  40. GIT=`which git`
  41. REV=$(${GIT} --git-dir "${srcdir}/.git" describe --tags `${GIT} --git-dir "${srcdir}/.git" rev-list --max-count=1 HEAD -- "src/${foldername}"`);
  42. echo "" >> META-INF/plugin.config
  43. echo "" >> META-INF/plugin.config
  44. echo "version:" >> META-INF/plugin.config;
  45. echo " number=$REV" >> META-INF/plugin.config;
  46. fi;
  47. foo=`echo $foldername | sed -e 's/\/[^\/]*$//g'`
  48. mkdir -p "$foo"
  49. cd "${foo}"
  50. ln -s "${destdir}/build/classes/${foldername}" .
  51. cd "$TMPDIR"
  52. mkdir -p "${destdir}/plugins/"
  53. rm -Rf "${destdir}/plugins/${2}.jar"
  54. jar -cvf "${srcdir}/src/${foldername}/${2}.jar" META-INF >/dev/null
  55. bit=""
  56. while [ 1 -eq 1 ]; do
  57. bit=${bit}/*
  58. ls ${foo}${bit}/* >/dev/null 2>&1
  59. if [ ${?} -ne 0 ]; then
  60. break;
  61. else
  62. DIR="${PWD}"
  63. for prepackage in `ls "${srcdir}/src/${foldername}${bit}/prePackage.sh" 2>/dev/null`; do
  64. cd `dirname "${prepackage}"`
  65. /bin/sh "${prepackage}"
  66. cd ${DIR}
  67. done;
  68. 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
  69. fi
  70. done
  71. mv "${srcdir}/src/${foldername}/${2}.jar" "${destdir}/plugins/"
  72. cd "${srcdir}"
  73. rm -Rf ${TMPDIR}
  74. #echo "done";