From: "Shawn O. Pearce" <spearce@spearce.org>
To: Robin Rosenberg <robin.rosenberg@dewire.com>
Cc: git@vger.kernel.org
Subject: [JGIT PATCH 2/3] Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper
Date: Tue, 2 Sep 2008 09:28:11 -0700 [thread overview]
Message-ID: <1220372892-15423-2-git-send-email-spearce@spearce.org> (raw)
In-Reply-To: <1220372892-15423-1-git-send-email-spearce@spearce.org>
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 <spearce@spearce.org>
---
.gitignore | 2 ++
make_jgit.sh | 54 ++++++++++++++++++++++++++++++++++++++++++------------
2 files changed, 44 insertions(+), 12 deletions(-)
diff --git a/.gitignore b/.gitignore
index 0763732..baf2766 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
/jgit
+/jgit.jar
+/jgit_src.zip
diff --git a/make_jgit.sh b/make_jgit.sh
index c119202..a15f73f 100755
--- a/make_jgit.sh
+++ b/make_jgit.sh
@@ -1,6 +1,9 @@
#!/bin/sh
-O=jgit
+O_CLI=jgit
+O_JAR=jgit.jar
+O_SRC=jgit_src.zip
+
PLUGINS="
org.spearce.jgit
org.spearce.jgit.pgm
@@ -11,7 +14,7 @@ JARS="
"
PSEP=":"
-T=".temp$$.$O"
+T=".temp$$.$O_CLI"
T_MF="$T.MF"
R=`pwd`
if [ "$OSTYPE" = "cygwin" ]
@@ -30,7 +33,7 @@ then
fi
cleanup_bin() {
- rm -f $T $O+ $T_MF
+ rm -f $T $O_CLI+ $O_JAR+ $O_SRC+ $T_MF
for p in $PLUGINS
do
rm -rf $p/bin2
@@ -39,13 +42,21 @@ cleanup_bin() {
die() {
cleanup_bin
- rm -f $O
+ rm -f $O_CLI $O_JAR $O_SRC
echo >&2 "$@"
exit 1
}
cleanup_bin
-rm -f $O
+rm -f $O_CLI $O_JAR $O_SRC
+
+VN=`git describe --abbrev=4 HEAD 2>/dev/null`
+git update-index -q --refresh
+if [ -n "`git diff-index --name-only HEAD --`" ]
+then
+ VN="$VN-dirty"
+fi
+VN=`echo "$VN" | sed -e s/-/./g`
CLASSPATH=
for j in $JARS
@@ -73,20 +84,39 @@ do
-d ../bin2) || die "Building $p failed."
CLASSPATH="${CLASSPATH}${PSEP}$R/$p/bin2"
done
+echo
+echo "Version $VN" &&
echo Manifest-Version: 1.0 >$T_MF &&
echo Implementation-Title: jgit >>$T_MF &&
-echo Implementation-Version: `git describe HEAD` >>$T_MF &&
+echo Implementation-Version: $VN >>$T_MF &&
+
+java org.spearce.jgit.pgm.build.JarLinkUtil \
+ -include org.spearce.jgit/bin2 \
+ -file META-INF/MANIFEST.MF=$T_MF \
+ >$O_JAR+ &&
+chmod 555 $O_JAR+ &&
+mv $O_JAR+ $O_JAR &&
+echo "Created $O_JAR." &&
+
+java org.spearce.jgit.pgm.build.JarLinkUtil \
+ -include org.spearce.jgit/src \
+ -file META-INF/MANIFEST.MF=$T_MF \
+ >$O_SRC+ &&
+chmod 555 $O_SRC+ &&
+mv $O_SRC+ $O_SRC &&
+echo "Created $O_SRC." &&
-sed s/@@use_self@@/1/ jgit.sh >$O+ &&
+M_TB=META-INF/services/org.spearce.jgit.pgm.TextBuiltin &&
+sed s/@@use_self@@/1/ jgit.sh >$O_CLI+ &&
java org.spearce.jgit.pgm.build.JarLinkUtil \
`for p in $JARS ; do printf %s " -include $p" ;done` \
`for p in $PLUGINS; do printf %s " -include $p/bin2";done` \
- -file META-INF/services/org.spearce.jgit.pgm.TextBuiltin=org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin \
+ -file $M_TB=org.spearce.jgit.pgm/src/$M_TB \
-file META-INF/MANIFEST.MF=$T_MF \
- >>$O+ &&
-chmod 555 $O+ &&
-mv $O+ $O &&
-echo "Created $O." || die "Creating $O failed."
+ >>$O_CLI+ &&
+chmod 555 $O_CLI+ &&
+mv $O_CLI+ $O_CLI &&
+echo "Created $O_CLI." || die "Build failed."
cleanup_bin
--
1.6.0.1.207.g020e5
next prev parent reply other threads:[~2008-09-02 16:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-02 16:28 [JGIT PATCH 1/3] Make all files in our JAR have the same timestamp Shawn O. Pearce
2008-09-02 16:28 ` Shawn O. Pearce [this message]
2008-09-02 16:28 ` [JGIT PATCH 3/3] Add a tiny "jgit version" program Shawn O. Pearce
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220372892-15423-2-git-send-email-spearce@spearce.org \
--to=spearce@spearce.org \
--cc=git@vger.kernel.org \
--cc=robin.rosenberg@dewire.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).