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.

make_jgit.sh 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #!/bin/sh
  2. # Copyright (C) 2009, Christian Halstrick <christian.halstrick@sap.com>
  3. # Copyright (C) 2008-2009, Google Inc.
  4. # Copyright (C) 2009, Johannes Schindelin <Johannes.Schindelin@gmx.de>
  5. # Copyright (C) 2008, Mike Ralphson <mike@abacus.co.uk>
  6. # Copyright (C) 2009, Mykola Nikishov <mn@mn.com.ua>
  7. # Copyright (C) 2009, Nicholas Campbell <nicholas.j.campbell@gmail.com>
  8. # Copyright (C) 2009, Robin Rosenberg <robin.rosenberg@gmail.com>
  9. # Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org>
  10. # and other copyright owners as documented in the project's IP log.
  11. #
  12. # This program and the accompanying materials are made available
  13. # under the terms of the Eclipse Distribution License v1.0 which
  14. # accompanies this distribution, is reproduced below, and is
  15. # available at http://www.eclipse.org/org/documents/edl-v10.php
  16. #
  17. # All rights reserved.
  18. #
  19. # Redistribution and use in source and binary forms, with or
  20. # without modification, are permitted provided that the following
  21. # conditions are met:
  22. #
  23. # - Redistributions of source code must retain the above copyright
  24. # notice, this list of conditions and the following disclaimer.
  25. #
  26. # - Redistributions in binary form must reproduce the above
  27. # copyright notice, this list of conditions and the following
  28. # disclaimer in the documentation and/or other materials provided
  29. # with the distribution.
  30. #
  31. # - Neither the name of the Eclipse Foundation, Inc. nor the
  32. # names of its contributors may be used to endorse or promote
  33. # products derived from this software without specific prior
  34. # written permission.
  35. #
  36. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
  37. # CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
  38. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  39. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  40. # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  41. # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  42. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  43. # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  44. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  45. # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  46. # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  47. # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  48. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  49. O_CLI=jgit
  50. O_JAR=jgit.jar
  51. O_SRC=jgit_src.zip
  52. O_DOC=jgit_docs.zip
  53. PLUGINS="
  54. org.eclipse.jgit
  55. org.eclipse.jgit.ui
  56. org.eclipse.jgit.pgm
  57. "
  58. JARS="
  59. org.eclipse.jgit/lib/jsch-0.1.37.jar
  60. org.eclipse.jgit.pgm/lib/args4j-2.0.9.jar
  61. "
  62. PSEP=":"
  63. T=".temp$$.$O_CLI"
  64. T_MF="$T.MF"
  65. R=`pwd`
  66. if [ "$OSTYPE" = "cygwin" ]
  67. then
  68. R=`cygpath -m $R`
  69. PSEP=";"
  70. fi
  71. if [ "$MSYSTEM" = "MINGW" -o "$MSYSTEM" = "MINGW32" ]
  72. then
  73. PSEP=";"
  74. R=`pwd -W`
  75. fi
  76. if [ -n "$JAVA_HOME" ]
  77. then
  78. PATH=${JAVA_HOME}/bin${PSEP}${PATH}
  79. fi
  80. cleanup_bin() {
  81. rm -f $T $O_CLI+ $O_JAR+ $O_SRC+ $T_MF
  82. for p in $PLUGINS
  83. do
  84. rm -rf $p/bin2
  85. done
  86. rm -rf docs
  87. }
  88. die() {
  89. cleanup_bin
  90. rm -f $O_CLI $O_JAR $O_SRC
  91. echo >&2 "$@"
  92. exit 1
  93. }
  94. cleanup_bin
  95. rm -f $O_CLI $O_JAR $O_SRC $O_DOC
  96. VN=`git describe --abbrev=4 HEAD 2>/dev/null`
  97. git update-index -q --refresh
  98. if [ -n "`git diff-index --name-only HEAD --`" ]
  99. then
  100. VN="$VN-dirty"
  101. fi
  102. VN=${VN:-untagged}`echo "$VN" | sed -e s/-/./g`
  103. CLASSPATH=
  104. for j in $JARS
  105. do
  106. if [ -z "$CLASSPATH" ]
  107. then
  108. CLASSPATH="$R/$j"
  109. else
  110. CLASSPATH="${CLASSPATH}${PSEP}$R/$j"
  111. fi
  112. done
  113. export CLASSPATH
  114. for p in $PLUGINS
  115. do
  116. echo "Entering $p ..."
  117. (cd $p/src &&
  118. mkdir ../bin2 &&
  119. find . -name \*.java -type f |
  120. xargs javac \
  121. -source 1.5 \
  122. -target 1.5 \
  123. -encoding UTF-8 \
  124. -g \
  125. -d ../bin2) || die "Building $p failed."
  126. CLASSPATH="${CLASSPATH}${PSEP}$R/$p/bin2"
  127. done
  128. echo
  129. echo "Version $VN" &&
  130. echo Manifest-Version: 1.0 >$T_MF &&
  131. echo Implementation-Title: jgit >>$T_MF &&
  132. echo Implementation-Version: $VN >>$T_MF &&
  133. java org.eclipse.jgit.pgm.build.JarLinkUtil \
  134. -include org.eclipse.jgit/bin2 \
  135. -file META-INF/MANIFEST.MF=$T_MF \
  136. >$O_JAR+ &&
  137. mv $O_JAR+ $O_JAR &&
  138. echo "Created $O_JAR." &&
  139. java org.eclipse.jgit.pgm.build.JarLinkUtil \
  140. -include org.eclipse.jgit/src \
  141. -file META-INF/MANIFEST.MF=$T_MF \
  142. >$O_SRC+ &&
  143. mv $O_SRC+ $O_SRC &&
  144. echo "Created $O_SRC." &&
  145. M_TB=META-INF/services/org.eclipse.jgit.pgm.TextBuiltin &&
  146. sed s/@@use_self@@/1/ jgit.sh >$O_CLI+ &&
  147. java org.eclipse.jgit.pgm.build.JarLinkUtil \
  148. `for p in $JARS ; do printf %s " -include $p" ;done` \
  149. `for p in $PLUGINS; do printf %s " -include $p/bin2";done` \
  150. -file $M_TB=org.eclipse.jgit.pgm/src/$M_TB \
  151. -file META-INF/MANIFEST.MF=$T_MF \
  152. >>$O_CLI+ &&
  153. chmod 555 $O_CLI+ &&
  154. mv $O_CLI+ $O_CLI &&
  155. echo "Created $O_CLI." || die "Build failed."
  156. echo "Building Javadocs ..."
  157. for p in $PLUGINS; do
  158. javadoc -quiet -sourcepath "$p/src/" -d "docs/$p/" \
  159. `find "$p/src" -name "*.java"`
  160. done
  161. (cd docs && jar cf "../$O_DOC" .)
  162. echo "Created $O_DOC."
  163. cleanup_bin