* [JGIT PATCH 1/3] Make all files in our JAR have the same timestamp
@ 2008-09-02 16:28 Shawn O. Pearce
2008-09-02 16:28 ` [JGIT PATCH 2/3] Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper Shawn O. Pearce
0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2008-09-02 16:28 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
When we link together our classes into a JAR we want to use the same
timestamp for all entries in the archive. Using different times from
the local filesystem is fairly meaningless.
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../org/spearce/jgit/pgm/build/JarLinkUtil.java | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java
index 46ae0ea..929ee55 100644
--- a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/build/JarLinkUtil.java
@@ -93,6 +93,8 @@ public static void main(final String[] argv) throws IOException {
private final Map<String, File> chosenSources = new HashMap<String, File>();
+ private long creationTime;
+
private ZipOutputStream zos;
private JarLinkUtil() {
@@ -109,6 +111,7 @@ private void run() throws IOException {
for (final Map.Entry<String, String> e : files.entrySet())
chosenSources.put(e.getKey(), new File(e.getValue()));
+ creationTime = System.currentTimeMillis();
zos = new ZipOutputStream(System.out);
zos.setLevel(9);
@@ -180,9 +183,8 @@ else if (chosenSources.get(pfx + e.getName()) == rootDir)
private void appendFile(final File path, final String name)
throws IOException {
final long len = path.length();
- final long time = path.lastModified();
final InputStream is = new FileInputStream(path);
- appendEntry(name, len, time, is);
+ appendEntry(name, len, creationTime, is);
}
private void appendEntry(final String name, final long len,
--
1.6.0.1.207.g020e5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [JGIT PATCH 2/3] Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper
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
2008-09-02 16:28 ` [JGIT PATCH 3/3] Add a tiny "jgit version" program Shawn O. Pearce
0 siblings, 1 reply; 3+ messages in thread
From: Shawn O. Pearce @ 2008-09-02 16:28 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [JGIT PATCH 3/3] Add a tiny "jgit version" program
2008-09-02 16:28 ` [JGIT PATCH 2/3] Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper Shawn O. Pearce
@ 2008-09-02 16:28 ` Shawn O. Pearce
0 siblings, 0 replies; 3+ messages in thread
From: Shawn O. Pearce @ 2008-09-02 16:28 UTC (permalink / raw)
To: Robin Rosenberg; +Cc: git
Displays the current version of the JAR. This is probably the same
as the library code since they are currently packaged together but
may in the future represent only the version of the CLI (.pgm).
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
.../services/org.spearce.jgit.pgm.TextBuiltin | 1 +
.../src/org/spearce/jgit/pgm/Version.java | 52 ++++++++++++++++++++
2 files changed, 53 insertions(+), 0 deletions(-)
create mode 100644 org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java
diff --git a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
index 39ae664..e2e7938 100644
--- a/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
+++ b/org.spearce.jgit.pgm/src/META-INF/services/org.spearce.jgit.pgm.TextBuiltin
@@ -12,6 +12,7 @@ org.spearce.jgit.pgm.RevList
org.spearce.jgit.pgm.Rm
org.spearce.jgit.pgm.ShowRev
org.spearce.jgit.pgm.Tag
+org.spearce.jgit.pgm.Version
org.spearce.jgit.pgm.debug.MakeCacheTree
org.spearce.jgit.pgm.debug.ReadDirCache
diff --git a/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java
new file mode 100644
index 0000000..e4cd707
--- /dev/null
+++ b/org.spearce.jgit.pgm/src/org/spearce/jgit/pgm/Version.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2008, Google Inc.
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or
+ * without modification, are permitted provided that the following
+ * conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ *
+ * - Neither the name of the Git Development Community nor the
+ * names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
+ * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+package org.spearce.jgit.pgm;
+
+@Command(common = true, usage = "Display the version of jgit")
+class Version extends TextBuiltin {
+ @Override
+ protected void run() throws Exception {
+ final Package pkg = getClass().getPackage();
+ if (pkg == null || pkg.getImplementationVersion() == null)
+ throw die("Cannot read package information.");
+
+ out.print("jgit version ");
+ out.print(pkg.getImplementationVersion());
+ out.println();
+ }
+}
--
1.6.0.1.207.g020e5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-09-02 16:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [JGIT PATCH 2/3] Build jgit.jar and jgit_src.zip alongside jgit CLI wrapper Shawn O. Pearce
2008-09-02 16:28 ` [JGIT PATCH 3/3] Add a tiny "jgit version" program Shawn O. Pearce
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).