EGit 0.4.0
[egit/chris.git] / make_jgit.sh
blob2969e6ec951e23f83f4da6214c7b7cafddbebf0d
1 #!/bin/sh
3 O_CLI=jgit
4 O_JAR=jgit.jar
5 O_SRC=jgit_src.zip
7 PLUGINS="
8 org.spearce.jgit
9 org.spearce.jgit.pgm
11 JARS="
12 org.spearce.jgit/lib/jsch-0.1.37.jar
13 org.spearce.jgit.pgm/lib/args4j-2.0.9.jar
16 PSEP=":"
17 T=".temp$$.$O_CLI"
18 T_MF="$T.MF"
19 R=`pwd`
20 if [ "$OSTYPE" = "cygwin" ]
21 then
22 R=`cygpath -m $R`
23 PSEP=";"
25 if [ "$MSYSTEM" = "MINGW" ]
26 then
27 PSEP=";"
30 if [ -n "$JAVA_HOME" ]
31 then
32 PATH=${JAVA_HOME}/bin${PSEP}${PATH}
35 cleanup_bin() {
36 rm -f $T $O_CLI+ $O_JAR+ $O_SRC+ $T_MF
37 for p in $PLUGINS
39 rm -rf $p/bin2
40 done
43 die() {
44 cleanup_bin
45 rm -f $O_CLI $O_JAR $O_SRC
46 echo >&2 "$@"
47 exit 1
50 cleanup_bin
51 rm -f $O_CLI $O_JAR $O_SRC
53 VN=`git describe --abbrev=4 HEAD 2>/dev/null`
54 git update-index -q --refresh
55 if [ -n "`git diff-index --name-only HEAD --`" ]
56 then
57 VN="$VN-dirty"
59 VN=`echo "$VN" | sed -e s/-/./g`
61 CLASSPATH=
62 for j in $JARS
64 if [ -z "$CLASSPATH" ]
65 then
66 CLASSPATH="$R/$j"
67 else
68 CLASSPATH="${CLASSPATH}${PSEP}$R/$j"
70 done
71 export CLASSPATH
73 for p in $PLUGINS
75 echo "Entering $p ..."
76 (cd $p/src &&
77 mkdir ../bin2 &&
78 find . -name \*.java -type f |
79 xargs javac \
80 -source 1.5 \
81 -target 1.5 \
82 -encoding UTF-8 \
83 -g \
84 -d ../bin2) || die "Building $p failed."
85 CLASSPATH="${CLASSPATH}${PSEP}$R/$p/bin2"
86 done
87 echo
89 echo "Version $VN" &&
90 echo Manifest-Version: 1.0 >$T_MF &&
91 echo Implementation-Title: jgit >>$T_MF &&
92 echo Implementation-Version: $VN >>$T_MF &&
94 java org.spearce.jgit.pgm.build.JarLinkUtil \
95 -include org.spearce.jgit/bin2 \
96 -file META-INF/MANIFEST.MF=$T_MF \
97 >$O_JAR+ &&
98 mv $O_JAR+ $O_JAR &&
99 echo "Created $O_JAR." &&
101 java org.spearce.jgit.pgm.build.JarLinkUtil \
102 -include org.spearce.jgit/src \
103 -file META-INF/MANIFEST.MF=$T_MF \
104 >$O_SRC+ &&
105 mv $O_SRC+ $O_SRC &&
106 echo "Created $O_SRC." &&
108 M_TB=META-INF/services/org.spearce.jgit.pgm.TextBuiltin &&
109 sed s/@@use_self@@/1/ jgit.sh >$O_CLI+ &&
110 java org.spearce.jgit.pgm.build.JarLinkUtil \
111 `for p in $JARS ; do printf %s " -include $p" ;done` \
112 `for p in $PLUGINS; do printf %s " -include $p/bin2";done` \
113 -file $M_TB=org.spearce.jgit.pgm/src/$M_TB \
114 -file META-INF/MANIFEST.MF=$T_MF \
115 >>$O_CLI+ &&
116 chmod 555 $O_CLI+ &&
117 mv $O_CLI+ $O_CLI &&
118 echo "Created $O_CLI." || die "Build failed."
120 cleanup_bin