Skip to content

Commit 7f62b2b

Browse files
spearcerobinrosenberg
authored andcommitted
Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper
When we build jgit the CLI executable we have the classes already compiled so we can easily construct a jgit.jar and jgit_src.zip at the same time. This makes it easier for folks who need the library and not the command line interface package. We do not include JSch in jgit.jar as we assume the downstream user can supply us the package. In an IDE scenario it is quite likely the IDE already has a copy of JSch available for use, so we really don't want to supply our own and potentially put two different versions on the classpath. The version we embed within our JAR manifest is now more like the dotted format used by C Git or git-gui. In particular we embed the "-dirty" suffix if the tree contains modifications. Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Robin Rosenberg <[email protected]>
1 parent 13bff2e commit 7f62b2b

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
/jgit
2+
/jgit.jar
3+
/jgit_src.zip

make_jgit.sh

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/sh
22

3-
O=jgit
3+
O_CLI=jgit
4+
O_JAR=jgit.jar
5+
O_SRC=jgit_src.zip
6+
47
PLUGINS="
58
org.spearce.jgit
69
org.spearce.jgit.pgm
@@ -11,7 +14,7 @@ JARS="
1114
"
1215

1316
PSEP=":"
14-
T=".temp$$.$O"
17+
T=".temp$$.$O_CLI"
1518
T_MF="$T.MF"
1619
R=`pwd`
1720
if [ "$OSTYPE" = "cygwin" ]
@@ -30,7 +33,7 @@ then
3033
fi
3134

3235
cleanup_bin() {
33-
rm -f $T $O+ $T_MF
36+
rm -f $T $O_CLI+ $O_JAR+ $O_SRC+ $T_MF
3437
for p in $PLUGINS
3538
do
3639
rm -rf $p/bin2
@@ -39,13 +42,21 @@ cleanup_bin() {
3942

4043
die() {
4144
cleanup_bin
42-
rm -f $O
45+
rm -f $O_CLI $O_JAR $O_SRC
4346
echo >&2 "$@"
4447
exit 1
4548
}
4649

4750
cleanup_bin
48-
rm -f $O
51+
rm -f $O_CLI $O_JAR $O_SRC
52+
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"
58+
fi
59+
VN=`echo "$VN" | sed -e s/-/./g`
4960

5061
CLASSPATH=
5162
for j in $JARS
@@ -73,20 +84,39 @@ do
7384
-d ../bin2) || die "Building $p failed."
7485
CLASSPATH="${CLASSPATH}${PSEP}$R/$p/bin2"
7586
done
87+
echo
7688

89+
echo "Version $VN" &&
7790
echo Manifest-Version: 1.0 >$T_MF &&
7891
echo Implementation-Title: jgit >>$T_MF &&
79-
echo Implementation-Version: `git describe HEAD` >>$T_MF &&
92+
echo Implementation-Version: $VN >>$T_MF &&
93+
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+
chmod 555 $O_JAR+ &&
99+
mv $O_JAR+ $O_JAR &&
100+
echo "Created $O_JAR." &&
101+
102+
java org.spearce.jgit.pgm.build.JarLinkUtil \
103+
-include org.spearce.jgit/src \
104+
-file META-INF/MANIFEST.MF=$T_MF \
105+
>$O_SRC+ &&
106+
chmod 555 $O_SRC+ &&
107+
mv $O_SRC+ $O_SRC &&
108+
echo "Created $O_SRC." &&
80109

81-
sed s/@@use_self@@/1/ jgit.sh >$O+ &&
110+
M_TB=META-INF/services/org.spearce.jgit.pgm.TextBuiltin &&
111+
sed s/@@use_self@@/1/ jgit.sh >$O_CLI+ &&
82112
java org.spearce.jgit.pgm.build.JarLinkUtil \
83113
`for p in $JARS ; do printf %s " -include $p" ;done` \
84114
`for p in $PLUGINS; do printf %s " -include $p/bin2";done` \
85-
-file META-INF/services/org.spearce.jgit.pgm.TextBuiltin=org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin \
115+
-file $M_TB=org.spearce.jgit.pgm/src/$M_TB \
86116
-file META-INF/MANIFEST.MF=$T_MF \
87-
>>$O+ &&
88-
chmod 555 $O+ &&
89-
mv $O+ $O &&
90-
echo "Created $O." || die "Creating $O failed."
117+
>>$O_CLI+ &&
118+
chmod 555 $O_CLI+ &&
119+
mv $O_CLI+ $O_CLI &&
120+
echo "Created $O_CLI." || die "Build failed."
91121

92122
cleanup_bin

0 commit comments

Comments
 (0)