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 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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-2009 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. # Channel to use for builds
  30. # TODO: Should be specified on command line somehow
  31. CHANNEL="STABLE"
  32. # Are we a git working copy, or SVN?
  33. if [ -e ".svn" ]; then
  34. isSVN=1
  35. else
  36. isSVN=0
  37. fi;
  38. # Go!
  39. echo "-----------"
  40. if [ -e "${RUNNAME}" ]; then
  41. echo "Removing existing file"
  42. rm -Rf ${RUNNAME}
  43. fi
  44. showHelp() {
  45. echo "This will generate a DMDirc jar file for any system with java on it."
  46. echo "The following command line arguments are known:"
  47. echo "---------------------"
  48. echo "-h, --help Help information"
  49. echo "-r, --release <version> Generate a file based on an svn tag (or branch with -b aswell)"
  50. echo "-b, --branch Release in -r is a branch "
  51. echo "-p, --plugins <plugins> What plugins to add to the jar file"
  52. echo "-c, --compile Recompile the .jar file (otherwise use the existing file from dist/)"
  53. echo " --jar <file> use <file> as DMDirc.jar (ie just add the plugins to it and rename)"
  54. echo " --current Use the current folder as the base for the build"
  55. echo "-e, --extra <tag> Tag to add to final name to distinguish this build from a standard build"
  56. echo "-k, --keep Keep the existing source tree when compiling"
  57. echo " (don't svn update beforehand)"
  58. echo "---------------------"
  59. exit 0;
  60. }
  61. # Check for some CLI params
  62. compileJar="false"
  63. updateSVN="true"
  64. isRelease=""
  65. finalTag=""
  66. BRANCH="0"
  67. plugins=""
  68. if [ $isSVN -eq 1 ]; then
  69. location="../../../"
  70. current=""
  71. else
  72. location="../../"
  73. current="1"
  74. fi;
  75. jarfile=""
  76. jre=""
  77. jrename="jre" # Filename for JRE without the .bin
  78. TAGGED=""
  79. while test -n "$1"; do
  80. case "$1" in
  81. --plugins|-p)
  82. shift
  83. plugins=${1}
  84. ;;
  85. --jar)
  86. shift
  87. jarfile=${1}
  88. ;;
  89. --current)
  90. location="../../"
  91. current="1"
  92. ;;
  93. --compile|-c)
  94. compileJar="true"
  95. ;;
  96. --release|-r)
  97. shift
  98. isRelease=${1}
  99. ;;
  100. --extra|-e)
  101. shift
  102. finalTag=${1}
  103. RUNNAME="${PWD}/${FILENAME}-${1}.jar"
  104. ;;
  105. --keep|-k)
  106. updateSVN="false"
  107. ;;
  108. --help|-h)
  109. showHelp;
  110. ;;
  111. --branch|-b)
  112. BRANCH="1"
  113. ;;
  114. --tag|-t)
  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. ;;
  124. esac
  125. shift
  126. done
  127. if [ "" = "${current}" ]; then
  128. jarPath="${location}trunk"
  129. else
  130. jarPath="${location}"
  131. fi
  132. if [ "${isRelease}" != "" ]; then
  133. if [ $isSVN -eq 1 ]; then
  134. if [ "${BRANCH}" != "0" ]; then
  135. if [ -e "${location}/${isRelease}" ]; then
  136. jarPath="${location}/${isRelease}"
  137. else
  138. echo "Branch "${isRelease}" not found."
  139. exit 1;
  140. fi
  141. else
  142. if [ -e "${location}/${isRelease}" ]; then
  143. jarPath="${location}/${isRelease}"
  144. else
  145. echo "Tag "${isRelease}" not found."
  146. exit 1;
  147. fi
  148. fi;
  149. fi
  150. fi
  151. if [ "" = "${jarfile}" ]; then
  152. jarfile=${jarPath}"/dist/DMDirc.jar"
  153. if [ ! -e ${jarPath}"/dist/DMDirc.jar" -o "${compileJar}" = "true" ]; then
  154. echo "Creating jar.."
  155. OLDPWD=${PWD}
  156. cd ${jarPath}
  157. if [ "${updateSVN}" = "true" ]; then
  158. if [ $isSVN -eq 1 ]; then
  159. svn update
  160. fi;
  161. fi
  162. ant -Dchannel=${channel} clean jar
  163. if [ ! -e "dist/DMDirc.jar" ]; then
  164. echo "There was an error creating the .jar file. Aborting."
  165. exit 1;
  166. fi;
  167. cd ${OLDPWD}
  168. fi;
  169. elif [ ! -e "${jarfile}" ]; then
  170. echo "Requested Jar file (${jarfile}) does not exist."
  171. exit 1;
  172. fi;
  173. echo "Copying jar (${jarfile}).."
  174. cp ${jarfile} ${RUNNAME}
  175. echo "Adding plugins to jar"
  176. ln -sf ${jarPath}"/plugins"
  177. pluginList=""
  178. for plugin in ${plugins}; do
  179. pluginList=${pluginList}" plugins/${plugin}"
  180. done
  181. jar -uvf "${RUNNAME}" ${pluginList}
  182. rm -Rf plugins;
  183. doRename=0
  184. if [ "${isRelease}" != "" ]; then
  185. doRename=1
  186. elif [ $isSVN -eq 0 -a "${TAGGED}" != "" ]; then
  187. doRename=1
  188. fi;
  189. if [ ${doRename} -eq 1 ]; then
  190. if [ $isSVN -eq 1 ]; then
  191. if [ "${BRANCH}" = "1" ]; then
  192. isRelease=branch-${isRelease}
  193. fi;
  194. else
  195. if [ "${TAGGED}" = "" ]; then
  196. isRelease=branch-${isRelease}
  197. else
  198. isRelease=${TAGGED}
  199. fi;
  200. fi
  201. if [ "" != "${finalTag}" ]; then
  202. finalTag="-${finalTag}"
  203. fi;
  204. finalname=DMDirc-${isRelease}${finalTag}.jar
  205. else
  206. finalname=${RUNNAME##*/}
  207. fi;
  208. mv ${RUNNAME} ../output/${finalname}
  209. echo "-----------"
  210. echo "Done."
  211. echo "-----------"
  212. # and Done \o
  213. exit 0;