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

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