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