Use MavenSession and Plexus to determine state.

- Fix bootstrap build.
This commit is contained in:
Roland Grunberg 2013-07-24 15:31:38 -04:00
parent f0a74e40b5
commit d351d154a0
5 changed files with 62 additions and 53 deletions

View File

@ -1,2 +1,2 @@
9cb3258a724ba3b141be77d7c7ffde23 maven-repo.tar.xz
2519253ad74fd2613f1ce3250a646d8a org.eclipse.tycho-tycho-0.18.x.tar.bz2
42dfaf1a7768e5ddb6268ae7e4ad2e11 maven-repo.tar.xz

View File

@ -1,4 +1,4 @@
From 4bd0fb083b6329ddc8df7b09dcfded3a45113a2f Mon Sep 17 00:00:00 2001
From 446e73cd3c2ef5ed8d5dc57615d88ef36445bafa Mon Sep 17 00:00:00 2001
From: Roland Grunberg <rgrunber@redhat.com>
Date: Mon, 19 Nov 2012 10:33:43 -0500
Subject: [PATCH] Minor fixes of limited scope to get a Tycho bootstrapped
@ -50,7 +50,7 @@ index 47423e5..4b4c600 100644
jetty.addConnector(connector);
diff --git a/tycho-bundles/tycho-bundles-target/tycho-bundles-target.target b/tycho-bundles/tycho-bundles-target/tycho-bundles-target.target
index 2063db2..bd011fe 100644
index 2a04214..400117a 100644
--- a/tycho-bundles/tycho-bundles-target/tycho-bundles-target.target
+++ b/tycho-bundles/tycho-bundles-target/tycho-bundles-target.target
@@ -2,16 +2,16 @@
@ -58,15 +58,14 @@ index 2063db2..bd011fe 100644
<locations>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="slicer" includeSource="false" type="InstallableUnit">
-<unit id="org.eclipse.equinox.executable.feature.group" version="3.6.0.v20130521-0416"/>
-<unit id="org.eclipse.sdk.ide" version="4.3.0.I20130526-0500"/>
-<unit id="org.eclipse.equinox.p2.sdk.feature.group" version="3.8.0.v20130526-0335"/>
-<unit id="org.eclipse.equinox.core.sdk.feature.group" version="3.8.0.v20130515-2026"/>
-<unit id="org.eclipse.sdk.ide" version="4.3.0.I20130605-2000"/>
-<unit id="org.eclipse.equinox.p2.sdk.feature.group" version="3.8.0.v20130604-2046"/>
-<unit id="org.eclipse.equinox.core.sdk.feature.group" version="3.8.0.v20130529-1710"/>
+<unit id="org.eclipse.equinox.executable.feature.group"/>
+<unit id="org.eclipse.sdk.ide"/>
+<unit id="org.eclipse.equinox.p2.sdk.feature.group"/>
+<unit id="org.eclipse.equinox.core.sdk.feature.group"/>
-<repository location="http://download.eclipse.org/eclipse/updates/4.3-I-builds/I20130526-0500/"/>
+<repository location="http://download.eclipse.org/eclipse/updates/4.3milestones/S-4.3M6-201303141330/"/>
<repository location="http://download.eclipse.org/releases/kepler/"/>
</location>
<location includeAllPlatforms="false" includeConfigurePhase="false" includeMode="slicer" includeSource="false" type="InstallableUnit">
<!-- required for surefire junit3 provider -->
@ -133,7 +132,7 @@ index 1aec480..0eeb0fa 100644
throw new OsgiManifestParserException(location, e);
}
diff --git a/tycho-surefire/pom.xml b/tycho-surefire/pom.xml
index 7dd7c41..62d5610 100644
index 7b9697c..43ab800 100644
--- a/tycho-surefire/pom.xml
+++ b/tycho-surefire/pom.xml
@@ -41,7 +41,7 @@

View File

@ -1,13 +0,0 @@
diff --git a/pom.xml b/pom.xml
index 5e398a8..6e94f51 100644
--- a/pom.xml
+++ b/pom.xml
@@ -143,7 +143,7 @@ $CMD -DpomFile=org.eclipse.jdt.compiler.apt.pom \
<jdtAptVersion>1.0.600.v20130530-1010</jdtAptVersion>
<!-- version of tycho used by this build -->
- <tychoBootstrapVersion>0.16.0</tychoBootstrapVersion>
+ <tychoBootstrapVersion>0.18.1-SNAPSHOT</tychoBootstrapVersion>
</properties>
<dependencyManagement>

View File

@ -1,4 +1,4 @@
From efb53f644836927c9f2693ee9d750ef83091ab83 Mon Sep 17 00:00:00 2001
From a1af94edb210feb59eecd372ce098c564ecd3656 Mon Sep 17 00:00:00 2001
From: Roland Grunberg <rgrunber@redhat.com>
Date: Tue, 12 Jun 2012 10:38:51 -0400
Subject: [PATCH] Implement a custom resolver for Tycho in local mode.
@ -29,18 +29,18 @@ Change-Id: Ia1ece07ece2412bc4a88901631f3f651ad2b634b
---
.../tycho/p2/target/TargetDefinitionResolver.java | 11 +++--
.../tycho/p2/target/TargetPlatformBuilderImpl.java | 55 ++++++++++++++++++++--
.../tycho/p2/repository/LocalRepositoryReader.java | 21 ++++++++-
.../tycho/p2/repository/LocalRepositoryReader.java | 22 ++++++++-
tycho-core/pom.xml | 5 ++
.../core/maven/TychoMavenLifecycleParticipant.java | 16 +++++++
.../core/maven/TychoMavenLifecycleParticipant.java | 28 +++++++++++
.../tycho/core/osgitools/AbstractTychoProject.java | 24 ++++++++++
.../tycho/core/osgitools/OsgiBundleProject.java | 29 +++++++++++-
.../DefaultTargetPlatformConfigurationReader.java | 6 ++-
.../osgi/runtime/TychoOsgiRuntimeLocator.java | 17 +++++++
.../p2/resolver/P2TargetPlatformResolver.java | 11 +++++
10 files changed, 184 insertions(+), 11 deletions(-)
10 files changed, 196 insertions(+), 12 deletions(-)
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetDefinitionResolver.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetDefinitionResolver.java
index 2dc91ff..34c48ff 100644
index 2dc91ff..8395f82 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetDefinitionResolver.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetDefinitionResolver.java
@@ -23,6 +23,7 @@ import org.eclipse.core.runtime.CoreException;
@ -59,7 +59,7 @@ index 2dc91ff..34c48ff 100644
- artifactRepositories.add(repository.getLocation());
- metadataRepositories.add(loadRepository(repository));
+ // We cannot resolve a non-file URI in local mode
+ if ((System.getenv("TYCHO_MVN_LOCAL") == null && System.getenv("TYCHO_MVN_RPMBUILD") == null)
+ if ((System.getProperty("TYCHO_MVN_LOCAL") == null && System.getProperty("TYCHO_MVN_RPMBUILD") == null)
+ || URIUtil.isFileURI(repository.getLocation())) {
+ repositoryIdManager.addMapping(repository.getId(), repository.getLocation());
+ artifactRepositories.add(repository.getLocation());
@ -69,7 +69,7 @@ index 2dc91ff..34c48ff 100644
IQueryable<IInstallableUnit> locationUnits = new CompoundQueryable<IInstallableUnit>(
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBuilderImpl.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBuilderImpl.java
index 5b61351..be3c47f 100644
index 5b61351..b81f6be 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBuilderImpl.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBuilderImpl.java
@@ -38,6 +38,9 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent;
@ -87,7 +87,7 @@ index 5b61351..be3c47f 100644
IArtifactRepository artifactRepository = null;
+ // We cannot resolve a non-file URI in local mode while offline
+ if (System.getenv("TYCHO_MVN_RPMBUILD") != null && !URIUtil.isFileURI(location.getURL())) {
+ if (System.getProperty("TYCHO_MVN_RPMBUILD") != null && !URIUtil.isFileURI(location.getURL())) {
+ return;
+ }
+
@ -103,7 +103,7 @@ index 5b61351..be3c47f 100644
- for (IMetadataRepository repository : metadataRepositories) {
- IQueryResult<IInstallableUnit> matches = repository.query(QueryUtil.ALL_UNITS, sub.newChild(100));
- result.addAll(matches.toUnmodifiableSet());
+ if (System.getenv("TYCHO_MVN_LOCAL") != null) {
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null) {
+ final String uri = "file:" + System.getProperty("user.dir") + "/.m2/p2/repo";
+ final IExpression notmatchIU_ID = ExpressionUtil.parse("id != $0");
+ IMetadataRepository systemLocalP2Repo = null;
@ -150,7 +150,7 @@ index 5b61351..be3c47f 100644
if (includeLocalMavenRepo && logger.isDebugEnabled()) {
IQueryResult<IInstallableUnit> locallyInstalledIUs = localMetadataRepository.query(QueryUtil.ALL_UNITS,
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java
index 8d36462..80182bd 100644
index 8d36462..5965699 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java
@@ -10,7 +10,9 @@
@ -163,14 +163,14 @@ index 8d36462..80182bd 100644
public class LocalRepositoryReader implements RepositoryReader {
@@ -21,7 +23,24 @@ public class LocalRepositoryReader implements RepositoryReader {
@@ -21,7 +23,23 @@ public class LocalRepositoryReader implements RepositoryReader {
}
public File getLocalArtifactLocation(GAV gav, String classifier, String extension) {
- return new File(localMavenRepositoryRoot, RepositoryLayoutHelper.getRelativePath(gav, classifier, extension));
- }
+ File file = new File(localMavenRepositoryRoot, RepositoryLayoutHelper.getRelativePath(gav, classifier, extension));
+ // In Fedora the artifact may be in an XMvn-defined repository location (not in reactor cache)
+ // A more sensible solution will be possible when upstream bug 353889 is resolved.
+ if (!file.exists()) {
+ String coord = gav.toString() + ":" + extension;
+ try {
@ -186,11 +186,11 @@ index 8d36462..80182bd 100644
+ }
+ }
+ return file;
}
+ }
}
diff --git a/tycho-core/pom.xml b/tycho-core/pom.xml
index 25ef342..72c5bb5 100644
index d1289b6..53cdc7a 100644
--- a/tycho-core/pom.xml
+++ b/tycho-core/pom.xml
@@ -146,6 +146,11 @@
@ -206,7 +206,7 @@ index 25ef342..72c5bb5 100644
<dependency>
<groupId>org.eclipse.tycho</groupId>
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java
index cccb6ff..fb8bf78 100644
index cccb6ff..c3a71f7 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/TychoMavenLifecycleParticipant.java
@@ -11,6 +11,7 @@
@ -217,12 +217,24 @@ index cccb6ff..fb8bf78 100644
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -73,6 +74,21 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic
@@ -73,6 +74,33 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic
registerExecutionListener(session);
configureComponents(session);
+ try {
+ if (plexus.lookup("org.fedoraproject.maven.resolver.Resolver") != null) {
+ if (session.isOffline()) {
+ System.setProperty("TYCHO_MVN_RPMBUILD", "");
+ } else {
+ System.setProperty("TYCHO_MVN_LOCAL", "");
+ }
+ }
+ } catch (ComponentLookupException e) {
+ // No XMvn (Upstream Maven in use)
+ }
+
+ // Create a system p2 repository for local dependency resolution
+ if (System.getenv("TYCHO_MVN_LOCAL") != null || System.getenv("TYCHO_MVN_RPMBUILD") != null) {
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null) {
+ try {
+ String[] cmd = new String[] { "/usr/share/java/tycho/copy-platform-all",
+ System.getProperty("user.dir") + "/.m2/p2/repo" };
@ -240,7 +252,7 @@ index cccb6ff..fb8bf78 100644
resolver.setupProject(session, project, DefaultReactorProject.adapt(project));
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java
index 695133d..ad25d9c 100644
index 695133d..542a0f7 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java
@@ -20,6 +20,9 @@ import org.eclipse.tycho.artifacts.TargetPlatform;
@ -274,7 +286,7 @@ index 695133d..ad25d9c 100644
+ try {
+ ExecutionEnvironment ee = ExecutionEnvironmentUtils.getExecutionEnvironment(profile);
+
+ if (System.getenv("TYCHO_MVN_LOCAL") != null || System.getenv("TYCHO_MVN_RPMBUILD") != null) {
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null) {
+ // EE must be at least JavaSE-1.6
+ final ExecutionEnvironment javaSE16 = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.6");
+ if (! ee.isCompatibleCompilerTargetLevel(javaSE16.getCompilerTargetLevelDefault())) {
@ -293,7 +305,7 @@ index 695133d..ad25d9c 100644
return (TargetPlatform) project.getContextValue(TychoConstants.CTX_TARGET_PLATFORM);
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java
index ab40599..3e64271 100644
index ab40599..4adb5da 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java
@@ -45,7 +45,9 @@ import org.eclipse.tycho.core.BundleProject;
@ -323,7 +335,7 @@ index ab40599..3e64271 100644
+ ExecutionEnvironment manifestMinimalEE = Collections.min(envs);
+ ExecutionEnvironment tmp;
+
+ if (System.getenv("TYCHO_MVN_LOCAL") != null || System.getenv("TYCHO_MVN_RPMBUILD") != null) {
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null) {
+ try {
+ // EE must be at least JavaSE-1.6
+ final ExecutionEnvironment javaSE16 = ExecutionEnvironmentUtils.getExecutionEnvironment("JavaSE-1.6");
@ -348,7 +360,7 @@ index ab40599..3e64271 100644
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
index edfc57b..d65b464 100644
index edfc57b..287cbca 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
@@ -64,7 +64,11 @@ public class DefaultTargetPlatformConfigurationReader {
@ -357,7 +369,7 @@ index edfc57b..d65b464 100644
- addTargetEnvironments(result, project, configuration);
+ // Use the defined environments only in local mode with tycho.local.keepTarget
+ if ((System.getenv("TYCHO_MVN_LOCAL") == null && System.getenv("TYCHO_MVN_RPMBUILD") == null)
+ if ((System.getProperty("TYCHO_MVN_LOCAL") == null && System.getProperty("TYCHO_MVN_RPMBUILD") == null)
+ || System.getProperty("tycho.local.keepTarget") != null) {
+ addTargetEnvironments(result, project, configuration);
+ }
@ -407,7 +419,7 @@ index 1e878e5..2de11ad 100644
request.setArtifact(artifact);
request.setResolveRoot(true).setResolveTransitively(false);
diff --git a/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java b/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
index f6f56ac..5abfd79 100644
index f6f56ac..b9b8cba 100644
--- a/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
+++ b/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
@@ -189,6 +189,17 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
@ -416,7 +428,7 @@ index f6f56ac..5abfd79 100644
tpBuilder.setFailOnDuplicateIUs(failOnDuplicateIUs);
+
+ // Add Fedora Local P2 Repository when running in local mode
+ if (System.getenv("TYCHO_MVN_LOCAL") != null || System.getenv("TYCHO_MVN_RPMBUILD") != null) {
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null) {
+ String uri = "file:" + System.getProperty("user.dir") + "/.m2/p2/repo";
+ try {
+ tpBuilder.addP2Repository(new MavenRepositoryLocation(uri, new URI(uri)));

View File

@ -1,6 +1,6 @@
# Bootstrap build
# Set this if Tycho and Eclipse are not in buildroot
%global bootstrap 0
%global bootstrap 1
# When building version under development (non-release)
# %%global snap -SNAPSHOT
%global snap %{nil}
@ -9,7 +9,7 @@
Name: tycho
Version: 0.18.1
Release: 1%{?dist}
Release: 1.1%{?dist}
Summary: Plugins and extensions for building Eclipse plugins and OSGI bundles with Maven
Group: Development/Libraries
@ -39,9 +39,6 @@ Patch3: %{name}-use-custom-resolver.patch
# a different version from the nonbootstrapped. Otherwise there will
# be cyclic dependencies.
Patch4: %{name}-bootstrap.patch
# Maven local mode will look in reactor cache for exact version (path lookup)
# Set the built intermediary version of Tycho to be found in the reactor cache
Patch5: %{name}-set-reactor-cache-version.patch
# Additional changes needed just for bootstrap build
Patch7: %{name}-fix-bootstrap-build.patch
@ -160,6 +157,11 @@ popd
%if %{bootstrap}
tar -xf %{SOURCE4}
# EXACT version in reactor cache to build against when bootstrapping
# If we built our own Tycho locally and put it into reactor cache instead
# of using upstream's then we need to make sure the build finds it.
sed -i 's/<tychoBootstrapVersion>0.16.0<\/tychoBootstrapVersion>/<tychoBootstrapVersion>0.18.0<\/tychoBootstrapVersion>/' pom.xml
# gid:aid used by bootstrapped build dependencies
mkdir -p .m2/org/ow2/asm/asm-debug-all/4.0/
pushd .m2/org/ow2/asm/asm-debug-all/4.0/
@ -169,6 +171,9 @@ popd
%patch7 -p1
# Tycho can't use cached composite repository metadata so use other type
sed -i 's/releases\/kepler\//releases\/kepler\/201306260900/' tycho-bundles/tycho-bundles-target/tycho-bundles-target.target
# Non-Bootstrap Build
%else
@ -192,7 +197,9 @@ echo "Performing intermediary build"
mvn-rpmbuild -Dmaven.local.depmap.file=%{SOURCE2} -DskipTychoVersionCheck -Dmaven.test.skip=true install javadoc:aggregate
%patch4 -p1 -R
%patch5 -p1
# EXACT version in reactor cache to build against (%%{version}-SNAPSHOT)
sed -i 's/<tychoBootstrapVersion>0.16.0<\/tychoBootstrapVersion>/<tychoBootstrapVersion>0.18.0-SNAPSHOT<\/tychoBootstrapVersion>/' pom.xml
fi
%endif
@ -283,6 +290,10 @@ install -m 644 $osgiJarPath $RPM_BUILD_ROOT%{_javadir}/%{name}/osgi.jar
%{_javadocdir}/%{name}
%changelog
* Wed Jul 24 2013 Roland Grunberg <rgrunber@redhat.com> - 0.18.1-1.1
- Use MavenSession and Plexus to determine state.
- Fix bootstrap build.
* Thu Jul 18 2013 Roland Grunberg <rgrunber@redhat.com> 0.18.1-1
- Make changes to ensure intermediary build succeeds.
- Remove %%Patch6 in favour of call to sed.