2009-09-30 01:47:03 +02:00
|
|
|
#!/bin/sh
|
2009-11-17 19:25:14 +01:00
|
|
|
# Copyright (C) 2009, Google Inc.
|
2009-09-30 01:47:03 +02:00
|
|
|
# and other copyright owners as documented in the project's IP log.
|
|
|
|
#
|
|
|
|
# This program and the accompanying materials are made available
|
|
|
|
# under the terms of the Eclipse Distribution License v1.0 which
|
|
|
|
# accompanies this distribution, is reproduced below, and is
|
|
|
|
# available at http://www.eclipse.org/org/documents/edl-v10.php
|
|
|
|
#
|
|
|
|
# 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 Eclipse Foundation, Inc. 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.
|
|
|
|
|
|
|
|
|
Switch build to Apache Felix maven-bundle-plugin
Tycho isn't production ready for projects like JGit to be using as
their primary build driver. Some problems we ran into with Tycho
0.6.0 that are preventing us from using it are:
* Tycho can't run offline
The P2 artifact resolver cannot perform its work offline. If the
build system has no network connection, it cannot compile a
project through Tycho. This is insane for a distributed version
control system where developers are used to being offline during
development and local testing.
* Magic state in ~/.m2/repository/.meta/p2-metadata.properties
Earlier iterations of this patch tried to use a hybrid build,
where Tycho was only used for the Eclipse specific feature and P2
update site, and maven-bundle-plugin was used for the other code.
This build seemed to work, but only due to magic Tycho specific
state held in my local home directory. This means builds are not
consistently repeatable across systems, and lead me to believe
I had a valid build, when in fact I did not.
* Manifest-first build produces incomplete POMs
The POM created by the manifest-first build format does not
contain the dependency chain, leading a downstream consumer to
not import the runtime dependencies necessary to execute the
bundle it has imported. In JGit's case, this means JSch isn't
included in our dependency chain.
* Manifest-first build produces POMs unreadable by Maven 2.x
JGit has existing application consumers who are relying on
Maven 2.x builds. Forcing them to step up to an alpha release
of Maven 3 is simply unacceptable.
* OSGi bundle export data management is tedious
Editing each of our pom.xml files to mark a new release is
difficult enough as it is. Editing every MANIFEST.MF file to
list our exported packages and their current version number is
something a machine should do, not a human. Yet the Tycho OSGi
way unfortunately demands that a human do this work.
* OSGi bundle import data management is tedious
There isn't a way in the MANIFEST.MF file format to reuse the
same version tags across all of our imports, but we want to have
a consistent view of our dependencies when we compile JGit.
After wasting more than 2 full days trying to get Tycho to work,
I've decided its a lost cause right now. We need to be chasing down
bugs and critical features, not trying to bridge the gap between
the stable Maven repository format and the undocumented P2 format
used only by Eclipse.
So, switch the build to use Apache Felix's maven-bundle-plugin.
This is the same plugin Jetty uses to produce their OSGi bundle
manifests, and is the same plugin used by the Apache Felix project,
which is an open-source OSGi runtime. It has a reasonable number
of folks using it for production builds, and is running on top of
the stable Maven 2.x code base.
With this switch we get automatically generated MANIFEST.MF files
based on reasonably sane default rules, which reduces the amount
of things we have to maintain by hand. When necessary, we can add
a few lines of XML to our POMs to tweak the output.
Our build artifacts are still fully compatible with Maven 2.x, so
any downstream consumers are still able to use our build products,
without stepping up to Maven 3.x. Our artifacts are also valid as
OSGi bundles, provided they are organized on disk into a repository
that the runtime can read.
With maven-bundle-plugin the build runs offline, as much as Maven
2.x is able to run offline anyway, so we're able to return to a
distributed development environment again.
By generating MANIFEST.MF at the top level of each project (and
therefore outside of the target directory), we're still compatible
with Eclipse's PDE tooling. Our projects can be imported as standard
Maven projects using the m2eclipse plugin, but the PDE will think
they are vaild plugins and make them available for plugin builds,
or while debugging another workbench.
This change also completely removes Tycho from the build.
Unfortunately, Tycho 0.6.0's pom-first dependency resolver is broken
when resolving a pom-first plugin bundle through a manifest-first
feature package, so bundle org.eclipse.jgit can't be resolved,
even though it might actually exist in the local Maven repository.
Rather than fight with Tycho any further, I'm just declaring it
plugina-non-grata and ripping it out of the build.
Since there are very few tools to build a P2 format repository, and
no documentation on how to create one without running the Eclipse
UI manually by poking buttons, I'm declaring that we are not going
to produce a P2 update site from our automated builds.
Change-Id: If7938a86fb0cc8e25099028d832dbd38110b9124
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2009-12-28 21:01:19 +01:00
|
|
|
# Update all pom.xml with new build number
|
2009-11-17 19:25:14 +01:00
|
|
|
#
|
|
|
|
# TODO(spearce) This should be converted to some sort of
|
|
|
|
# Java based Maven plugin so its fully portable.
|
|
|
|
#
|
2009-09-30 01:47:03 +02:00
|
|
|
|
2009-11-17 19:25:14 +01:00
|
|
|
case "$1" in
|
|
|
|
--snapshot=*)
|
|
|
|
V=$(echo "$1" | perl -pe 's/^--snapshot=//')
|
|
|
|
if [ -z "$V" ]
|
|
|
|
then
|
|
|
|
echo >&2 "usage: $0 --snapshot=0.n.0"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
case "$V" in
|
|
|
|
*-SNAPSHOT) : ;;
|
|
|
|
*) V=$V-SNAPSHOT ;;
|
|
|
|
esac
|
|
|
|
;;
|
2009-09-30 01:47:03 +02:00
|
|
|
|
2009-11-17 19:25:14 +01:00
|
|
|
--release)
|
|
|
|
V=$(git describe HEAD) || exit
|
|
|
|
;;
|
2009-09-30 01:47:03 +02:00
|
|
|
|
2009-11-17 19:25:14 +01:00
|
|
|
*)
|
|
|
|
echo >&2 "usage: $0 {--snapshot=0.n.0 | --release}"
|
|
|
|
exit 1
|
|
|
|
esac
|
2009-09-30 01:47:03 +02:00
|
|
|
|
2009-11-17 19:25:14 +01:00
|
|
|
case "$V" in
|
|
|
|
v*) V=$(echo "$V" | perl -pe s/^v//) ;;
|
|
|
|
esac
|
2009-09-30 01:47:03 +02:00
|
|
|
|
2009-11-17 19:25:14 +01:00
|
|
|
case "$V" in
|
|
|
|
*-SNAPSHOT)
|
|
|
|
POM_V=$V
|
2010-03-19 03:18:37 +01:00
|
|
|
OSGI_V="${V%%-SNAPSHOT}.qualifier"
|
2009-11-17 19:25:14 +01:00
|
|
|
;;
|
|
|
|
*-[1-9]*-g[0-9a-f]*)
|
|
|
|
POM_V=$(echo "$V" | perl -pe 's/-(\d+-g.*)$/.$1/')
|
2010-03-19 03:18:37 +01:00
|
|
|
OSGI_V=$(perl -e '
|
2011-06-24 23:09:20 +02:00
|
|
|
die unless $ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?(?:\.\d{12}-r)?)?-(\d+)-g(.*)$/;
|
2010-03-19 03:18:37 +01:00
|
|
|
my ($a, $b, $c, $p, $r) = ($1, $2, $3, $4, $5);
|
|
|
|
$b = '0' unless defined $b;
|
|
|
|
$c = '0' unless defined $c;
|
|
|
|
|
|
|
|
printf "%s.%s.%s.%6.6i_g%s\n", $a, $b, $c, $p, $r;
|
|
|
|
' "$V")
|
2009-11-17 19:25:14 +01:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
POM_V=$V
|
2010-03-19 03:18:37 +01:00
|
|
|
OSGI_V=$V
|
2009-11-17 19:25:14 +01:00
|
|
|
;;
|
|
|
|
esac
|
2009-09-30 01:47:03 +02:00
|
|
|
|
2010-03-19 03:18:37 +01:00
|
|
|
API_V=$(perl -e '
|
|
|
|
$ARGV[0] =~ /^(\d+(?:\.\d+(?:\.\d+)?)?)/;
|
|
|
|
print $1
|
|
|
|
' "$V")
|
|
|
|
|
|
|
|
API_N=$(perl -e '
|
|
|
|
$ARGV[0] =~ /^(\d+)(?:\.(\d+)(?:\.(\d+))?)?/;
|
|
|
|
my ($a, $b) = ($1, $2);
|
|
|
|
$b = 0 unless defined $b;
|
|
|
|
$b++;
|
|
|
|
print "$a.$b.0";
|
|
|
|
' "$API_V")
|
|
|
|
|
2010-06-14 17:18:47 +02:00
|
|
|
perl -pi~ -e '
|
2010-03-19 03:18:37 +01:00
|
|
|
s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/;
|
|
|
|
s/(org.eclipse.jgit.*;version=")[^"[(]*(")/${1}'"$API_V"'${2}/;
|
|
|
|
s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/;
|
|
|
|
' $(git ls-files | grep META-INF/MANIFEST.MF)
|
|
|
|
|
2011-02-11 23:03:40 +01:00
|
|
|
perl -pi~ -e '
|
|
|
|
s/^(Bundle-Version:\s*).*$/${1}'"$OSGI_V"'/;
|
|
|
|
s/(org.eclipse.jgit.*;version=")[^"[(]*(")/${1}'"$API_V"'${2}/;
|
|
|
|
s/(org.eclipse.jgit.*;version="\[)[^"]*(\)")/${1}'"$API_V,$API_N"'${2}/;
|
2014-04-18 01:11:49 +02:00
|
|
|
s/^(Eclipse-SourceBundle:\s*org.eclipse.jgit.*;version=\").*(\";roots=\"\.\")$/${1}'"$OSGI_V"'${2}/;
|
2011-02-11 23:03:40 +01:00
|
|
|
' $(git ls-files | grep META-INF/SOURCE-MANIFEST.MF)
|
|
|
|
|
2010-06-14 17:18:47 +02:00
|
|
|
perl -pi~ -e '
|
2010-03-19 03:18:37 +01:00
|
|
|
if ($ARGV ne $old_argv) {
|
|
|
|
$seen_version = 0;
|
|
|
|
$old_argv = $ARGV;
|
|
|
|
}
|
|
|
|
if (!$seen_version) {
|
|
|
|
$seen_version = 1 if (!/<\?xml/ &&
|
|
|
|
s/(version=")[^"]*(")/${1}'"$OSGI_V"'${2}/);
|
|
|
|
}
|
2017-04-05 14:48:00 +02:00
|
|
|
s/(import feature="org\.eclipse\.jgit.*" version=")[^"]*(")/${1}'"$API_V"'${2}/;
|
2010-06-02 23:30:11 +02:00
|
|
|
' org.eclipse.jgit.packaging/org.*.feature/feature.xml
|
2010-03-19 03:18:37 +01:00
|
|
|
|
2010-06-14 17:18:47 +02:00
|
|
|
perl -pi~ -e '
|
2013-06-04 13:58:24 +02:00
|
|
|
if ($ARGV ne $old_argv) {
|
|
|
|
$seen_version = 0;
|
|
|
|
$old_argv = $ARGV;
|
|
|
|
}
|
|
|
|
if (!$seen_version) {
|
|
|
|
$seen_version = 1 if
|
|
|
|
s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>};
|
|
|
|
}
|
2010-06-02 23:30:11 +02:00
|
|
|
' org.eclipse.jgit.packaging/org.*.feature/pom.xml
|
2010-03-19 03:18:37 +01:00
|
|
|
|
2011-02-11 23:03:40 +01:00
|
|
|
perl -pi~ -e '
|
|
|
|
if ($ARGV ne $old_argv) {
|
|
|
|
$seen_version = 0;
|
|
|
|
$old_argv = $ARGV;
|
|
|
|
}
|
2013-06-04 13:58:24 +02:00
|
|
|
if (!$seen_version) {
|
|
|
|
$seen_version = 1 if
|
2011-02-11 23:03:40 +01:00
|
|
|
s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>};
|
|
|
|
}
|
|
|
|
' org.eclipse.jgit.packaging/pom.xml
|
|
|
|
|
2019-01-17 02:55:11 +01:00
|
|
|
perl -pi~ -e '
|
|
|
|
if ($ARGV ne $old_argv) {
|
|
|
|
$seen_version = 0;
|
|
|
|
$old_argv = $ARGV;
|
|
|
|
}
|
|
|
|
if ($seen_version < 18) {
|
|
|
|
$seen_version++ if
|
|
|
|
s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>};
|
|
|
|
}
|
|
|
|
' org.eclipse.jgit.coverage/pom.xml
|
|
|
|
|
2010-06-14 17:18:47 +02:00
|
|
|
perl -pi~ -e '
|
2009-11-17 19:25:14 +01:00
|
|
|
if ($ARGV ne $old_argv) {
|
|
|
|
$seen_version = 0;
|
|
|
|
$old_argv = $ARGV;
|
|
|
|
}
|
|
|
|
if (!$seen_version) {
|
|
|
|
$seen_version = 1 if
|
Switch build to Apache Felix maven-bundle-plugin
Tycho isn't production ready for projects like JGit to be using as
their primary build driver. Some problems we ran into with Tycho
0.6.0 that are preventing us from using it are:
* Tycho can't run offline
The P2 artifact resolver cannot perform its work offline. If the
build system has no network connection, it cannot compile a
project through Tycho. This is insane for a distributed version
control system where developers are used to being offline during
development and local testing.
* Magic state in ~/.m2/repository/.meta/p2-metadata.properties
Earlier iterations of this patch tried to use a hybrid build,
where Tycho was only used for the Eclipse specific feature and P2
update site, and maven-bundle-plugin was used for the other code.
This build seemed to work, but only due to magic Tycho specific
state held in my local home directory. This means builds are not
consistently repeatable across systems, and lead me to believe
I had a valid build, when in fact I did not.
* Manifest-first build produces incomplete POMs
The POM created by the manifest-first build format does not
contain the dependency chain, leading a downstream consumer to
not import the runtime dependencies necessary to execute the
bundle it has imported. In JGit's case, this means JSch isn't
included in our dependency chain.
* Manifest-first build produces POMs unreadable by Maven 2.x
JGit has existing application consumers who are relying on
Maven 2.x builds. Forcing them to step up to an alpha release
of Maven 3 is simply unacceptable.
* OSGi bundle export data management is tedious
Editing each of our pom.xml files to mark a new release is
difficult enough as it is. Editing every MANIFEST.MF file to
list our exported packages and their current version number is
something a machine should do, not a human. Yet the Tycho OSGi
way unfortunately demands that a human do this work.
* OSGi bundle import data management is tedious
There isn't a way in the MANIFEST.MF file format to reuse the
same version tags across all of our imports, but we want to have
a consistent view of our dependencies when we compile JGit.
After wasting more than 2 full days trying to get Tycho to work,
I've decided its a lost cause right now. We need to be chasing down
bugs and critical features, not trying to bridge the gap between
the stable Maven repository format and the undocumented P2 format
used only by Eclipse.
So, switch the build to use Apache Felix's maven-bundle-plugin.
This is the same plugin Jetty uses to produce their OSGi bundle
manifests, and is the same plugin used by the Apache Felix project,
which is an open-source OSGi runtime. It has a reasonable number
of folks using it for production builds, and is running on top of
the stable Maven 2.x code base.
With this switch we get automatically generated MANIFEST.MF files
based on reasonably sane default rules, which reduces the amount
of things we have to maintain by hand. When necessary, we can add
a few lines of XML to our POMs to tweak the output.
Our build artifacts are still fully compatible with Maven 2.x, so
any downstream consumers are still able to use our build products,
without stepping up to Maven 3.x. Our artifacts are also valid as
OSGi bundles, provided they are organized on disk into a repository
that the runtime can read.
With maven-bundle-plugin the build runs offline, as much as Maven
2.x is able to run offline anyway, so we're able to return to a
distributed development environment again.
By generating MANIFEST.MF at the top level of each project (and
therefore outside of the target directory), we're still compatible
with Eclipse's PDE tooling. Our projects can be imported as standard
Maven projects using the m2eclipse plugin, but the PDE will think
they are vaild plugins and make them available for plugin builds,
or while debugging another workbench.
This change also completely removes Tycho from the build.
Unfortunately, Tycho 0.6.0's pom-first dependency resolver is broken
when resolving a pom-first plugin bundle through a manifest-first
feature package, so bundle org.eclipse.jgit can't be resolved,
even though it might actually exist in the local Maven repository.
Rather than fight with Tycho any further, I'm just declaring it
plugina-non-grata and ripping it out of the build.
Since there are very few tools to build a P2 format repository, and
no documentation on how to create one without running the Eclipse
UI manually by poking buttons, I'm declaring that we are not going
to produce a P2 update site from our automated builds.
Change-Id: If7938a86fb0cc8e25099028d832dbd38110b9124
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
2009-12-28 21:01:19 +01:00
|
|
|
s{<(version)>.*</\1>}{<${1}>'"$POM_V"'</${1}>};
|
2009-11-17 19:25:14 +01:00
|
|
|
}
|
|
|
|
' $(git ls-files | grep pom.xml)
|
|
|
|
|
2010-06-14 17:18:47 +02:00
|
|
|
find . -name '*~' | xargs rm -f
|
2009-11-17 19:25:14 +01:00
|
|
|
git diff
|