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.

makeJar.sh 6.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. #!/bin/sh
  2. #
  3. # This script generates a jar file for a release version of DMDirc
  4. #
  5. # DMDirc - Open Source IRC Client
  6. # Copyright (c) 2006-2010 Chris Smith, Shane Mc Cormack, Gregory Holmes
  7. #
  8. # Permission is hereby granted, free of charge, to any person obtaining a copy
  9. # of this software and associated documentation files (the "Software"), to deal
  10. # in the Software without restriction, including without limitation the rights
  11. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. # copies of the Software, and to permit persons to whom the Software is
  13. # furnished to do so, subject to the following conditions:
  14. #
  15. # The above copyright notice and this permission notice shall be included in
  16. # all copies or substantial portions of the Software.
  17. #
  18. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  24. # SOFTWARE.
  25. # Final Name of the file (without file extention)
  26. FILENAME=DMDirc
  27. # full name of the file to output to
  28. RUNNAME="${PWD}/${FILENAME}.jar"
  29. # Are we a git working copy, or SVN?
  30. if [ -e ".svn" ]; then
  31. isSVN=1
  32. else
  33. isSVN=0
  34. fi;
  35. # Go!
  36. echo "-----------"
  37. if [ -e "${RUNNAME}" ]; then
  38. echo "Removing existing file"
  39. rm -Rf ${RUNNAME}
  40. fi
  41. showHelp() {
  42. echo "This will generate a DMDirc jar file for any system with java on it."
  43. echo "The following command line arguments are known:"
  44. echo "---------------------"
  45. echo "-h, --help Help information"
  46. echo "-r, --release <version> Generate a file based on an svn tag (or branch with -b as well)"
  47. echo "-b, --branch Release in -r is a branch "
  48. echo "-p, --plugins <plugins> What plugins to add to the jar file"
  49. echo "-c, --compile Recompile the .jar file (otherwise use the existing file from dist/)"
  50. echo " --jar <file> use <file> as DMDirc.jar (ie just add the plugins to it and rename)"
  51. echo " --current Use the current folder as the base for the build"
  52. echo "-e, --extra <tag> Tag to add to final name to distinguish this build from a standard build"
  53. echo "-k, --keep Keep the existing source tree when compiling"
  54. echo " (don't svn update beforehand)"
  55. echo " --channel [channel] Channel to pass to ant (if not passed, 'NONE', if passed without a value, 'STABLE')"
  56. echo "---------------------"
  57. exit 0;
  58. }
  59. # Check for some CLI params
  60. compileJar="false"
  61. updateSVN="true"
  62. isRelease=""
  63. finalTag=""
  64. BRANCH="0"
  65. plugins=""
  66. if [ $isSVN -eq 1 ]; then
  67. location="../../../"
  68. current=""
  69. else
  70. location="../../"
  71. current="1"
  72. fi;
  73. jarfile=""
  74. jre=""
  75. jrename="jre" # Filename for JRE without the .bin
  76. TAGGED=""
  77. CHANNEL="NONE"
  78. while test -n "$1"; do
  79. case "$1" in
  80. --plugins|-p)
  81. shift
  82. plugins=${1}
  83. ;;
  84. --jar)
  85. shift
  86. jarfile=${1}
  87. ;;
  88. --current)
  89. location="../../"
  90. current="1"
  91. ;;
  92. --compile|-c)
  93. compileJar="true"
  94. ;;
  95. --release|-r)
  96. shift
  97. isRelease=${1}
  98. ;;
  99. --extra|-e)
  100. shift
  101. finalTag=${1}
  102. RUNNAME="${PWD}/${FILENAME}-${1}.jar"
  103. ;;
  104. --keep|-k)
  105. updateSVN="false"
  106. ;;
  107. --help|-h)
  108. showHelp;
  109. ;;
  110. --branch|-b)
  111. BRANCH="1"
  112. ;;
  113. --tag|-t)
  114. if [ ${isSVN} -eq 1 ]; then
  115. shift
  116. REGEX="^[0-9]+(\.[0-9]+(\.[0-9]+)?)?$"
  117. CHECKTAG=`echo ${1} | egrep "${REGEX}"`
  118. if [ "" = "${CHECKTAG}" ]; then
  119. echo "Specified tag ("${1}") is invalid."
  120. exit 1;
  121. fi;
  122. TAGGED="${1}"
  123. else
  124. TAGGED=`git describe --tags`
  125. TAGGED=${TAGGED%%-*}
  126. fi;
  127. ;;
  128. --channel)
  129. PASSEDPARAM=`echo "${2}" | grep -v ^-`
  130. if [ "${PASSEDPARAM}" != "" ]; then
  131. shift
  132. CHANNEL=${PASSEDPARAM};
  133. else
  134. CHANNEL="STABLE";
  135. fi;
  136. ;;
  137. esac
  138. shift
  139. done
  140. if [ "" = "${current}" ]; then
  141. jarPath="${location}trunk"
  142. else
  143. jarPath="${location}"
  144. fi
  145. if [ "${isRelease}" != "" ]; then
  146. if [ $isSVN -eq 1 ]; then
  147. if [ "${BRANCH}" != "0" ]; then
  148. if [ -e "${location}/${isRelease}" ]; then
  149. jarPath="${location}/${isRelease}"
  150. else
  151. echo "Branch "${isRelease}" not found."
  152. exit 1;
  153. fi
  154. else
  155. if [ -e "${location}/${isRelease}" ]; then
  156. jarPath="${location}/${isRelease}"
  157. else
  158. echo "Tag "${isRelease}" not found."
  159. exit 1;
  160. fi
  161. fi;
  162. fi
  163. fi
  164. if [ "" = "${jarfile}" ]; then
  165. jarfile=${jarPath}"/dist/DMDirc.jar"
  166. if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
  167. echo "Creating jar.."
  168. OLDPWD=${PWD}
  169. cd ${jarPath}
  170. if [ "${updateSVN}" = "true" ]; then
  171. if [ $isSVN -eq 1 ]; then
  172. svn update
  173. fi;
  174. fi
  175. ant -Dchannel=${CHANNEL} clean jar
  176. if [ ! -e "dist/DMDirc.jar" ]; then
  177. echo "There was an error creating the .jar file. Aborting."
  178. exit 1;
  179. fi;
  180. cd ${OLDPWD}
  181. fi;
  182. elif [ ! -e "${jarfile}" ]; then
  183. echo "Requested Jar file (${jarfile}) does not exist."
  184. exit 1;
  185. fi;
  186. echo "Copying jar (${jarfile} -> ${RUNNAME}).."
  187. cp ${jarfile} ${RUNNAME}
  188. # Remove plugins added by createAllPluginJar
  189. zip -d ${RUNNAME} plugins plugins/*
  190. if [ "${plugins}" != "" ]; then
  191. echo "Adding plugins to jar"
  192. ln -sf ${jarPath}"/plugins"
  193. pluginList=""
  194. for plugin in ${plugins}; do
  195. pluginList=${pluginList}" plugins/${plugin}"
  196. done
  197. jar -uvf "${RUNNAME}" ${pluginList}
  198. rm -Rf plugins;
  199. fi;
  200. doRename=0
  201. if [ "${isRelease}" != "" ]; then
  202. doRename=1
  203. elif [ $isSVN -eq 0 -a "${TAGGED}" != "" ]; then
  204. doRename=1
  205. fi;
  206. if [ ${doRename} -eq 1 ]; then
  207. if [ $isSVN -eq 1 ]; then
  208. if [ "${BRANCH}" = "1" ]; then
  209. isRelease=branch-${isRelease}
  210. fi;
  211. else
  212. if [ "${TAGGED}" = "" ]; then
  213. isRelease=branch-${isRelease}
  214. else
  215. isRelease=${TAGGED}
  216. fi;
  217. fi
  218. if [ "" != "${finalTag}" ]; then
  219. finalTag="-${finalTag}"
  220. fi;
  221. finalname=DMDirc-${isRelease}${finalTag}.jar
  222. else
  223. finalname=${RUNNAME##*/}
  224. fi;
  225. mv ${RUNNAME} ../output/${finalname}
  226. echo "-----------"
  227. echo "Done."
  228. echo "-----------"
  229. # and Done \o
  230. exit 0;