805cfaf66d
- Look for any IU if IU/Version query fails in target definition resolver.
694 lines
38 KiB
Diff
694 lines
38 KiB
Diff
From a8aaa1b1e97b9173f9a0816b6918faffd75817e6 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.
|
|
|
|
When running in local mode, dependencies should be resolved by looking
|
|
on the local system. Remote repositories should be ignored unless
|
|
offline mode is disabled.
|
|
|
|
Use fedoraproject-p2 to resolve bundles from their system location.
|
|
|
|
Relax constraints for bundles used in Tycho's Equinox runtime.
|
|
|
|
Since Fedora 17, we need an Execution Environment of at least JavaSE-1.6
|
|
for Eclipse bundles. Eclipse Juno platform bundles depend on
|
|
javax.annotation. In Fedora this is provided by geronimo-annotation, but
|
|
has a dependency on javax.lang.model (since 1.6).
|
|
|
|
Use the defined target environments in local mode when the property
|
|
tycho.local.keepTarget is set.
|
|
|
|
In situations where Tycho must resolve maven artifacts, upstream's
|
|
implementation only looks in the reactor cache. In Fedora, maven
|
|
artifacts may be located on the system using repository layouts
|
|
understood by XMvn. Therefore, when an artifact is not found in the
|
|
reactor cache, resolution should be attempted using the XMvn Resolver.
|
|
|
|
Change-Id: Ia1ece07ece2412bc4a88901631f3f651ad2b634b
|
|
---
|
|
.../embedder/internal/DefaultEquinoxEmbedder.java | 11 ++++-
|
|
.../META-INF/MANIFEST.MF | 3 +-
|
|
.../p2/remote/RemoteRepositoryCacheManager.java | 14 +++++++
|
|
.../tycho/p2/target/TargetDefinitionResolver.java | 48 ++++++++++++++++++++--
|
|
.../p2/target/TargetPlatformBundlePublisher.java | 15 ++-----
|
|
.../tycho/p2/target/TargetPlatformFactoryImpl.java | 45 ++++++++++++++++++--
|
|
.../tycho/p2/repository/LocalRepositoryReader.java | 44 +++++++++++++++++++-
|
|
.../facade/TargetPlatformConfigurationStub.java | 6 ++-
|
|
.../tycho-bundles-external.product | 1 +
|
|
.../eclipse/tycho/core/locking/FileLockerImpl.java | 26 +++++++++---
|
|
.../core/maven/TychoMavenLifecycleParticipant.java | 13 ++++++
|
|
.../tycho/core/osgitools/AbstractTychoProject.java | 23 +++++++++++
|
|
.../tycho/core/osgitools/OsgiBundleProject.java | 29 ++++++++++++-
|
|
.../DefaultTargetPlatformConfigurationReader.java | 6 ++-
|
|
tycho-p2/tycho-p2-facade/pom.xml | 5 +++
|
|
.../tycho/p2/resolver/P2DependencyResolver.java | 30 ++++++++++++++
|
|
16 files changed, 287 insertions(+), 32 deletions(-)
|
|
|
|
diff --git a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java
|
|
index ed01c2d..759f005 100644
|
|
--- a/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java
|
|
+++ b/sisu-equinox/sisu-equinox-embedder/src/main/java/org/eclipse/sisu/equinox/embedder/internal/DefaultEquinoxEmbedder.java
|
|
@@ -230,7 +230,14 @@ public class DefaultEquinoxEmbedder extends AbstractLogEnabled implements Equino
|
|
if (verIdx > 0) {
|
|
bundles.append(name.substring(0, verIdx));
|
|
} else {
|
|
- throw new EquinoxEmbedderException("File name doesn't match expected pattern: " + file);
|
|
+ // In Fedora, NAME_VERSION.QUALIFIER.jar is too fragile.
|
|
+ // Let's also accept NAME.jar
|
|
+ verIdx = name.lastIndexOf(".jar");
|
|
+ if (verIdx > 0) {
|
|
+ bundles.append(name.substring(0, verIdx));
|
|
+ } else {
|
|
+ throw new EquinoxEmbedderException("File name doesn't match expected pattern: " + file);
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
@@ -238,7 +245,7 @@ public class DefaultEquinoxEmbedder extends AbstractLogEnabled implements Equino
|
|
}
|
|
|
|
protected boolean isFrameworkBundle(File file) {
|
|
- return file.getName().startsWith("org.eclipse.osgi_");
|
|
+ return file.getName().startsWith("org.eclipse.osgi_") || file.getName().equals("org.eclipse.osgi.jar");
|
|
}
|
|
|
|
String getReferenceUrl(File file) {
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/META-INF/MANIFEST.MF b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/META-INF/MANIFEST.MF
|
|
index cc5e9b3..85ff778 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/META-INF/MANIFEST.MF
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/META-INF/MANIFEST.MF
|
|
@@ -18,7 +18,8 @@ Require-Bundle: org.eclipse.core.runtime,
|
|
org.eclipse.equinox.p2.repository;bundle-version="2.0.0",
|
|
org.eclipse.equinox.p2.updatesite;bundle-version="1.0.200",
|
|
org.eclipse.core.net;bundle-version="1.2.100",
|
|
- org.eclipse.tycho.p2.maven.repository;bundle-version="0.12.0"
|
|
+ org.eclipse.tycho.p2.maven.repository;bundle-version="0.12.0",
|
|
+ org.fedoraproject.p2
|
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
|
Bundle-ActivationPolicy: lazy
|
|
Export-Package: org.eclipse.tycho.p2.impl;x-friends:="org.eclipse.tycho.p2.impl.test",
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java
|
|
index 707b1c5..c8c4152 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/remote/RemoteRepositoryCacheManager.java
|
|
@@ -12,12 +12,19 @@ package org.eclipse.tycho.p2.remote;
|
|
|
|
import java.io.File;
|
|
import java.io.IOException;
|
|
+import java.net.MalformedURLException;
|
|
import java.net.URI;
|
|
+import java.net.URL;
|
|
|
|
import org.eclipse.core.runtime.IProgressMonitor;
|
|
+import org.eclipse.core.runtime.IStatus;
|
|
+import org.eclipse.core.runtime.Status;
|
|
+import org.eclipse.equinox.internal.p2.repository.Activator;
|
|
import org.eclipse.equinox.internal.p2.repository.CacheManager;
|
|
+import org.eclipse.equinox.internal.p2.repository.Messages;
|
|
import org.eclipse.equinox.internal.p2.repository.Transport;
|
|
import org.eclipse.equinox.p2.core.ProvisionException;
|
|
+import org.eclipse.osgi.util.NLS;
|
|
import org.eclipse.tycho.core.facade.MavenContext;
|
|
import org.eclipse.tycho.core.facade.MavenLogger;
|
|
|
|
@@ -48,6 +55,13 @@ class RemoteRepositoryCacheManager extends CacheManager {
|
|
@Override
|
|
public File createCache(URI repositoryLocation, String prefix, IProgressMonitor monitor) throws IOException,
|
|
ProvisionException {
|
|
+ try {
|
|
+ new URL(repositoryLocation.toASCIIString());
|
|
+ } catch (MalformedURLException e) {
|
|
+ throw new ProvisionException(new Status(IStatus.ERROR, Activator.ID,
|
|
+ ProvisionException.REPOSITORY_NOT_FOUND, NLS.bind(Messages.CacheManager_CannotLoadNonUrlLocation,
|
|
+ repositoryLocation), null));
|
|
+ }
|
|
File cacheFile = getCache(repositoryLocation, prefix);
|
|
if (offline) {
|
|
if (cacheFile != null) {
|
|
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 e8f7c3f..b34512a 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
|
|
@@ -11,9 +11,11 @@
|
|
package org.eclipse.tycho.p2.target;
|
|
|
|
import java.net.URI;
|
|
+import java.nio.file.Paths;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collections;
|
|
+import java.util.HashSet;
|
|
import java.util.Iterator;
|
|
import java.util.LinkedHashSet;
|
|
import java.util.List;
|
|
@@ -22,6 +24,7 @@ import java.util.Set;
|
|
import org.eclipse.core.runtime.CoreException;
|
|
import org.eclipse.core.runtime.IProgressMonitor;
|
|
import org.eclipse.core.runtime.IStatus;
|
|
+import org.eclipse.core.runtime.URIUtil;
|
|
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
|
import org.eclipse.equinox.p2.core.ProvisionException;
|
|
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
|
@@ -51,6 +54,7 @@ import org.eclipse.tycho.p2.util.resolution.ProjectorResolutionStrategy;
|
|
import org.eclipse.tycho.p2.util.resolution.SlicerResolutionStrategy;
|
|
import org.eclipse.tycho.repository.util.DuplicateFilteringLoggingProgressMonitor;
|
|
import org.eclipse.tycho.repository.util.StatusTool;
|
|
+import org.fedoraproject.p2.EclipseSystemLayout;
|
|
|
|
/**
|
|
* Class which performs target definition resolution. This class is used by the
|
|
@@ -122,9 +126,35 @@ public class TargetDefinitionResolver {
|
|
|
|
List<IMetadataRepository> metadataRepositories = new ArrayList<IMetadataRepository>();
|
|
for (Repository repository : iuLocationDefinition.getRepositories()) {
|
|
- repositoryIdManager.addMapping(repository.getId(), repository.getLocation());
|
|
- artifactRepositories.add(repository.getLocation());
|
|
- metadataRepositories.add(loadRepository(repository));
|
|
+ // We cannot resolve a non-file URI in local mode
|
|
+ if ((System.getProperty("TYCHO_MVN_LOCAL") == null && System.getProperty("TYCHO_MVN_RPMBUILD") == null)
|
|
+ || URIUtil.isFileURI(repository.getLocation())
|
|
+ || "fedora".equals(repository.getLocation().getScheme())) {
|
|
+ repositoryIdManager.addMapping(repository.getId(), repository.getLocation());
|
|
+ artifactRepositories.add(repository.getLocation());
|
|
+ metadataRepositories.add(loadRepository(repository));
|
|
+ }
|
|
+ }
|
|
+ // Add Fedora Local P2 Repository when running in local mode
|
|
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null) {
|
|
+ final Set<String> allLocations = new HashSet<String>();
|
|
+ final Set<String> roots = EclipseSystemLayout.getSCLRoots();
|
|
+
|
|
+ for (String root : roots) {
|
|
+ EclipseSystemLayout.initLocations(Paths.get(root), allLocations, allLocations, allLocations, false);
|
|
+ }
|
|
+ allLocations.addAll(EclipseSystemLayout.getUserDefinedBundleLocations());
|
|
+
|
|
+ for (String loc : allLocations) {
|
|
+ try {
|
|
+ String uri = "fedora:" + loc;
|
|
+ URI location = new URI(uri);
|
|
+ repositoryIdManager.addMapping(uri, location);
|
|
+ artifactRepositories.add(location);
|
|
+ metadataRepositories.add(metadataManager.loadRepository(location, monitor));
|
|
+ } catch (Exception e) {
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
IQueryable<IInstallableUnit> locationUnits = new CompoundQueryable<IInstallableUnit>(
|
|
@@ -236,6 +266,18 @@ public class TargetDefinitionResolver {
|
|
IQuery<IInstallableUnit> latestMatchingIUQuery = QueryUtil.createLatestQuery(matchingIUQuery);
|
|
|
|
IQueryResult<IInstallableUnit> queryResult = units.query(latestMatchingIUQuery, monitor);
|
|
+
|
|
+ // If the iu/version can't be located then try to use an iu of any version
|
|
+ if ((System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null)
|
|
+ && queryResult.isEmpty()) {
|
|
+ logger.warn(NLS.bind("Could not find \"{0}/{1}\" in the repositories of the current location",
|
|
+ unitReference.getId(), unitReference.getVersion()));
|
|
+ logger.warn(NLS.bind("Attempting to look for \"{0}\" instead.", unitReference.getId()));
|
|
+ matchingIUQuery = QueryUtil.createIUQuery(unitReference.getId());
|
|
+ latestMatchingIUQuery = QueryUtil.createLatestQuery(matchingIUQuery);
|
|
+ queryResult = units.query(latestMatchingIUQuery, monitor);
|
|
+ }
|
|
+
|
|
return queryResult;
|
|
}
|
|
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisher.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisher.java
|
|
index 5d6bc1f..8281167 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisher.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisher.java
|
|
@@ -28,6 +28,7 @@ import org.eclipse.tycho.core.facade.MavenLogger;
|
|
import org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice;
|
|
import org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository;
|
|
import org.eclipse.tycho.p2.metadata.IArtifactFacade;
|
|
+import org.eclipse.tycho.p2.repository.LocalRepositoryReader;
|
|
import org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates;
|
|
import org.eclipse.tycho.repository.local.GAVArtifactDescriptor;
|
|
import org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider;
|
|
@@ -218,15 +219,6 @@ public class TargetPlatformBundlePublisher {
|
|
GAVArtifactDescriptor descriptorForRepository = new GAVArtifactDescriptor(baseDescriptor,
|
|
repositoryCoordinates);
|
|
|
|
- File requiredArtifactLocation = new File(getBaseDir(), descriptorForRepository.getMavenCoordinates()
|
|
- .getLocalRepositoryPath());
|
|
- File actualArtifactLocation = mavenArtifact.getLocation();
|
|
- if (!equivalentPaths(requiredArtifactLocation, actualArtifactLocation)) {
|
|
- throw new AssertionFailedException(
|
|
- "The Maven artifact to be added to the target platform is not stored at the required location on disk: required \""
|
|
- + requiredArtifactLocation + "\" but was \"" + actualArtifactLocation + "\"");
|
|
- }
|
|
-
|
|
internalAddInternalDescriptor(descriptorForRepository);
|
|
}
|
|
|
|
@@ -259,8 +251,9 @@ public class TargetPlatformBundlePublisher {
|
|
|
|
@Override
|
|
protected File internalGetArtifactStorageLocation(IArtifactDescriptor descriptor) {
|
|
- String relativePath = toInternalDescriptor(descriptor).getMavenCoordinates().getLocalRepositoryPath();
|
|
- return new File(getBaseDir(), relativePath);
|
|
+ MavenRepositoryCoordinates coord = toInternalDescriptor(descriptor).getMavenCoordinates();
|
|
+ LocalRepositoryReader reader = new LocalRepositoryReader(getBaseDir());
|
|
+ return reader.getLocalArtifactLocation(coord.getGav(), coord.getClassifier(), coord.getExtensionOrDefault());
|
|
}
|
|
|
|
private File getBaseDir() {
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java
|
|
index 6554f43..334c425 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java
|
|
@@ -32,6 +32,9 @@ import org.eclipse.core.runtime.URIUtil;
|
|
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
|
import org.eclipse.equinox.p2.core.ProvisionException;
|
|
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
|
|
+import org.eclipse.equinox.p2.metadata.expression.ExpressionUtil;
|
|
+import org.eclipse.equinox.p2.metadata.expression.IExpression;
|
|
+import org.eclipse.equinox.p2.query.IQuery;
|
|
import org.eclipse.equinox.p2.query.IQueryResult;
|
|
import org.eclipse.equinox.p2.query.QueryUtil;
|
|
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
|
|
@@ -272,9 +275,43 @@ public class TargetPlatformFactoryImpl implements TargetPlatformFactory {
|
|
metadataRepositories.add(localMetadataRepository);
|
|
}
|
|
|
|
- for (IMetadataRepository repository : metadataRepositories) {
|
|
- IQueryResult<IInstallableUnit> matches = repository.query(QueryUtil.ALL_UNITS, monitor);
|
|
- result.addAll(matches.toUnmodifiableSet());
|
|
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null) {
|
|
+ final IExpression notmatchIU_ID = ExpressionUtil.parse("id != $0");
|
|
+ Set<IMetadataRepository> fedoraRepos = new HashSet<IMetadataRepository> ();
|
|
+
|
|
+ // Sanity check even though the repo we want should be at index 1
|
|
+ for (IMetadataRepository repository : metadataRepositories) {
|
|
+ if ("fedora".equals(repository.getLocation().getScheme())) {
|
|
+ fedoraRepos.add(repository);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ IQuery<IInstallableUnit> noLocalIUs = QueryUtil.createIUAnyQuery();
|
|
+
|
|
+ // Create a conjunction query that negates all IUs on the local system
|
|
+ for (IMetadataRepository repo : fedoraRepos) {
|
|
+ for (IInstallableUnit unit : repo.query(QueryUtil.ALL_UNITS, null).toUnmodifiableSet()) {
|
|
+ noLocalIUs = QueryUtil.createCompoundQuery(noLocalIUs,
|
|
+ QueryUtil.createMatchQuery(notmatchIU_ID, unit.getId()), true);
|
|
+ }
|
|
+ }
|
|
+
|
|
+ for (IMetadataRepository repository : metadataRepositories) {
|
|
+ IQueryResult<IInstallableUnit> matches;
|
|
+ if ("fedora".equals(repository.getLocation().getScheme())) {
|
|
+ matches = repository.query(QueryUtil.ALL_UNITS, monitor);
|
|
+ } else {
|
|
+ // Don't collect any remote IUs that can be found on the system
|
|
+ // This will favour IUs in the system local p2 repository
|
|
+ matches = repository.query(noLocalIUs, monitor);
|
|
+ }
|
|
+ result.addAll(matches.toUnmodifiableSet());
|
|
+ }
|
|
+ } else {
|
|
+ for (IMetadataRepository repository : metadataRepositories) {
|
|
+ IQueryResult<IInstallableUnit> matches = repository.query(QueryUtil.ALL_UNITS, monitor);
|
|
+ result.addAll(matches.toUnmodifiableSet());
|
|
+ }
|
|
}
|
|
|
|
result.addAll(pomDependenciesContent.gatherMavenInstallableUnits());
|
|
@@ -322,7 +359,7 @@ public class TargetPlatformFactoryImpl implements TargetPlatformFactory {
|
|
List<URI> allRemoteArtifactRepositories = new ArrayList<URI>();
|
|
|
|
for (MavenRepositoryLocation location : completeRepositories) {
|
|
- if (!offline || URIUtil.isFileURI(location.getURL())) {
|
|
+ if (!offline || URIUtil.isFileURI(location.getURL()) || "fedora".equals(location.getURL().getScheme())) {
|
|
allRemoteArtifactRepositories.add(location.getURL());
|
|
}
|
|
}
|
|
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..b5c8c55 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
|
|
@@ -11,6 +11,8 @@
|
|
package org.eclipse.tycho.p2.repository;
|
|
|
|
import java.io.File;
|
|
+import java.lang.reflect.Constructor;
|
|
+import java.lang.reflect.Method;
|
|
|
|
public class LocalRepositoryReader implements RepositoryReader {
|
|
|
|
@@ -20,8 +22,46 @@ public class LocalRepositoryReader implements RepositoryReader {
|
|
this.localMavenRepositoryRoot = localMavenRepositoryRoot;
|
|
}
|
|
|
|
+ @SuppressWarnings({ "unchecked", "rawtypes" })
|
|
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)
|
|
+ if (!file.exists()) {
|
|
+ try {
|
|
+ // Create Plexus config
|
|
+ Class pcclazz = Class.forName("org.codehaus.plexus.ContainerConfiguration");
|
|
+ Object conf = Class.forName("org.codehaus.plexus.DefaultContainerConfiguration").newInstance();
|
|
+ pcclazz.getMethod("setAutoWiring", boolean.class).invoke(conf, true);
|
|
+ pcclazz.getMethod("setClassPathScanning", String.class).invoke(conf, "index");
|
|
+
|
|
+ // Use plexus container to lookup the reader
|
|
+ Class pclazz = Class.forName("org.codehaus.plexus.DefaultPlexusContainer");
|
|
+ Object plexus = pclazz.getConstructor(pcclazz).newInstance(conf);
|
|
+
|
|
+ // Retrieve the workspace reader from the plexus container
|
|
+ Method mLookup = pclazz.getMethod("lookup", String.class, String.class);
|
|
+ Object reader = mLookup.invoke(plexus, "org.eclipse.aether.repository.WorkspaceReader", "ide");
|
|
|
|
+ // Create an Aether Artifact based on GAV, classifier, and extension
|
|
+ Class iartclazz = Class.forName("org.eclipse.aether.artifact.Artifact");
|
|
+ Class artclazz = Class.forName("org.eclipse.aether.artifact.DefaultArtifact");
|
|
+ Constructor cNew = artclazz.getConstructor(String.class, String.class, String.class, String.class,
|
|
+ String.class);
|
|
+ Object artifact = cNew.newInstance(gav.getGroupId(), gav.getArtifactId(), classifier, extension,
|
|
+ gav.getVersion());
|
|
+
|
|
+ // Invoke "findArtifact" method of the workspace reader on the artifact
|
|
+ Method mfindArtifact = reader.getClass().getMethod("findArtifact", iartclazz);
|
|
+ File newFile = (File) mfindArtifact.invoke(reader, artifact);
|
|
+ if (newFile != null) {
|
|
+ file = newFile;
|
|
+ }
|
|
+ } catch (Exception e) {
|
|
+ e.printStackTrace();
|
|
+ }
|
|
+ }
|
|
+ return file;
|
|
+
|
|
+ }
|
|
}
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java
|
|
index 9505cb5..41bd9ad 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java
|
|
@@ -56,7 +56,11 @@ public class TargetPlatformConfigurationStub {
|
|
}
|
|
|
|
public void addP2Repository(MavenRepositoryLocation location) {
|
|
- this.repositories.add(location);
|
|
+ // We cannot resolve a non-file URI in local mode while offline
|
|
+ if (System.getProperty("TYCHO_MVN_RPMBUILD") == null || "file".equalsIgnoreCase(location.getURL().getScheme())
|
|
+ || "fedora".equalsIgnoreCase(location.getURL().getScheme())) {
|
|
+ this.repositories.add(location);
|
|
+ }
|
|
}
|
|
|
|
// convenience method for tests
|
|
diff --git a/tycho-bundles/tycho-bundles-external/tycho-bundles-external.product b/tycho-bundles/tycho-bundles-external/tycho-bundles-external.product
|
|
index 41705c5..c7399cb 100644
|
|
--- a/tycho-bundles/tycho-bundles-external/tycho-bundles-external.product
|
|
+++ b/tycho-bundles/tycho-bundles-external/tycho-bundles-external.product
|
|
@@ -76,6 +76,7 @@
|
|
<plugin id="org.eclipse.tycho.noopsecurity"/>
|
|
<plugin id="org.sat4j.core"/>
|
|
<plugin id="org.sat4j.pb"/>
|
|
+ <plugin id="org.fedoraproject.p2"/>
|
|
</plugins>
|
|
|
|
<configurations>
|
|
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/locking/FileLockerImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/core/locking/FileLockerImpl.java
|
|
index 86253bd..cef15d2 100644
|
|
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/locking/FileLockerImpl.java
|
|
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/locking/FileLockerImpl.java
|
|
@@ -27,22 +27,36 @@ public class FileLockerImpl implements FileLocker {
|
|
final File lockMarkerFile;
|
|
|
|
public FileLockerImpl(File file, Location anyLocation) {
|
|
+ File lockFileCandidate = null;
|
|
try {
|
|
if (file.isDirectory()) {
|
|
- this.lockMarkerFile = new File(file, LOCKFILE_SUFFIX).getCanonicalFile();
|
|
+ lockFileCandidate = new File(file, LOCKFILE_SUFFIX).getCanonicalFile();
|
|
} else {
|
|
- this.lockMarkerFile = new File(file.getParentFile(), file.getName() + LOCKFILE_SUFFIX)
|
|
- .getCanonicalFile();
|
|
+ lockFileCandidate = new File(file.getParentFile(), file.getName() + LOCKFILE_SUFFIX).getCanonicalFile();
|
|
}
|
|
- if (lockMarkerFile.isDirectory()) {
|
|
- throw new RuntimeException("Lock marker file " + lockMarkerFile + " already exists and is a directory");
|
|
+
|
|
+ if (lockFileCandidate.isDirectory()) {
|
|
+ throw new RuntimeException("Lock marker file " + lockFileCandidate + " already exists and is a directory");
|
|
}
|
|
- File parentDir = lockMarkerFile.getParentFile();
|
|
+ File parentDir = lockFileCandidate.getParentFile();
|
|
if (!parentDir.isDirectory() && !parentDir.mkdirs()) {
|
|
throw new RuntimeException("Could not create parent directory " + parentDir + " of lock marker file");
|
|
}
|
|
+
|
|
+ String baseDir = System.getProperty("user.dir");
|
|
+ String reactorCache = baseDir + "/.m2/";
|
|
+ // In Fedora we can only assume reactor cache is safe for read/write.
|
|
+ if (!lockFileCandidate.getAbsolutePath().startsWith(reactorCache)) {
|
|
+ String lockFileDir = reactorCache + LOCKFILE_SUFFIX;
|
|
+ // If the file is located within baseDir, no need to repeat
|
|
+ String lockFileName = file.getAbsolutePath().replace(baseDir, "").replace("/", "-").replaceFirst("-", "/") + LOCKFILE_SUFFIX;
|
|
+ lockFileCandidate = new File(lockFileDir, lockFileName);
|
|
+ }
|
|
+
|
|
+ this.lockMarkerFile = lockFileCandidate;
|
|
this.lockFileLocation = anyLocation.createLocation(null, null, false);
|
|
this.lockFileLocation.set(lockMarkerFile.toURL(), false, lockMarkerFile.getAbsolutePath());
|
|
+
|
|
} catch (MalformedURLException e) {
|
|
throw new RuntimeException(e);
|
|
} catch (IOException e) {
|
|
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 59335b9..77e7c7e 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
|
|
@@ -29,6 +29,7 @@ import org.apache.maven.project.MavenProject;
|
|
import org.codehaus.plexus.PlexusContainer;
|
|
import org.codehaus.plexus.component.annotations.Component;
|
|
import org.codehaus.plexus.component.annotations.Requirement;
|
|
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
|
|
import org.codehaus.plexus.logging.Logger;
|
|
import org.eclipse.tycho.ReactorProject;
|
|
import org.eclipse.tycho.core.osgitools.BundleReader;
|
|
@@ -66,6 +67,18 @@ public class TychoMavenLifecycleParticipant extends AbstractMavenLifecyclePartic
|
|
validate(projects);
|
|
configureComponents(session);
|
|
|
|
+ try {
|
|
+ if (plexus.lookup("org.fedoraproject.xmvn.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)
|
|
+ }
|
|
+
|
|
for (MavenProject project : projects) {
|
|
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 f2602ec..c5755a0 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
|
|
@@ -19,6 +19,9 @@ import org.eclipse.tycho.artifacts.DependencyArtifacts;
|
|
import org.eclipse.tycho.core.TargetPlatformConfiguration;
|
|
import org.eclipse.tycho.core.TychoConstants;
|
|
import org.eclipse.tycho.core.TychoProject;
|
|
+import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils;
|
|
+import org.eclipse.tycho.core.ee.UnknownEnvironmentException;
|
|
+import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment;
|
|
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration;
|
|
import org.eclipse.tycho.core.facade.TargetEnvironment;
|
|
import org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver;
|
|
@@ -91,15 +94,35 @@ public abstract class AbstractTychoProject extends AbstractLogEnabled implements
|
|
|
|
String configuredForcedProfile = tpConfiguration.getExecutionEnvironment();
|
|
if (configuredForcedProfile != null) {
|
|
+ configuredForcedProfile = overrideToAtLeastJavaSE16(configuredForcedProfile);
|
|
sink.overrideProfileConfiguration(configuredForcedProfile,
|
|
"target-platform-configuration <executionEnvironment>");
|
|
}
|
|
|
|
String configuredDefaultProfile = tpConfiguration.getExecutionEnvironmentDefault();
|
|
if (configuredDefaultProfile != null) {
|
|
+ configuredDefaultProfile = overrideToAtLeastJavaSE16(configuredDefaultProfile);
|
|
sink.setProfileConfiguration(configuredDefaultProfile,
|
|
"target-platform-configuration <executionEnvironmentDefault>");
|
|
}
|
|
}
|
|
|
|
+ public String overrideToAtLeastJavaSE16 (String profile) {
|
|
+ try {
|
|
+ ExecutionEnvironment ee = ExecutionEnvironmentUtils.getExecutionEnvironment(profile);
|
|
+
|
|
+ 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())) {
|
|
+ ee = javaSE16;
|
|
+ }
|
|
+ }
|
|
+
|
|
+ return ee.getProfileName();
|
|
+ } catch (UnknownEnvironmentException e) {
|
|
+ // can't happen, ee is validated during configuration parsing
|
|
+ return null;
|
|
+ }
|
|
+ }
|
|
}
|
|
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 f7f5df1..710c8a9 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
|
|
@@ -47,7 +47,9 @@ import org.eclipse.tycho.core.BundleProject;
|
|
import org.eclipse.tycho.core.PluginDescription;
|
|
import org.eclipse.tycho.core.TychoConstants;
|
|
import org.eclipse.tycho.core.TychoProject;
|
|
+import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils;
|
|
import org.eclipse.tycho.core.ee.StandardExecutionEnvironment;
|
|
+import org.eclipse.tycho.core.ee.UnknownEnvironmentException;
|
|
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment;
|
|
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration;
|
|
import org.eclipse.tycho.core.facade.BuildPropertiesParser;
|
|
@@ -489,6 +491,7 @@ public class OsgiBundleProject extends AbstractTychoProject implements BundlePro
|
|
String pdeProfile = getEclipsePluginProject(DefaultReactorProject.adapt(project)).getBuildProperties()
|
|
.getJreCompilationProfile();
|
|
if (pdeProfile != null) {
|
|
+ pdeProfile = overrideToAtLeastJavaSE16(pdeProfile);
|
|
sink.setProfileConfiguration(pdeProfile.trim(), "build.properties");
|
|
|
|
} else {
|
|
@@ -506,7 +509,31 @@ public class OsgiBundleProject extends AbstractTychoProject implements BundlePro
|
|
if (envs.isEmpty()) {
|
|
return null;
|
|
}
|
|
- return Collections.min(envs);
|
|
+
|
|
+ ExecutionEnvironment manifestMinimalEE = Collections.min(envs);
|
|
+ ExecutionEnvironment tmp;
|
|
+
|
|
+ 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");
|
|
+ while (!envs.isEmpty()) {
|
|
+ tmp = Collections.min(envs);
|
|
+ if (tmp.isCompatibleCompilerTargetLevel(javaSE16.getCompilerTargetLevelDefault())) {
|
|
+ manifestMinimalEE = tmp;
|
|
+ break;
|
|
+ }
|
|
+ envs.remove(tmp);
|
|
+ }
|
|
+
|
|
+ if (envs.isEmpty()) {
|
|
+ return javaSE16;
|
|
+ }
|
|
+ } catch (UnknownEnvironmentException e) {
|
|
+ // Continue
|
|
+ }
|
|
+ }
|
|
+ return manifestMinimalEE;
|
|
}
|
|
|
|
}
|
|
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 4a1f157..65cbf47 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 {
|
|
+ configuration.toString());
|
|
}
|
|
|
|
- addTargetEnvironments(result, project, configuration);
|
|
+ // Use the defined environments only in local mode with tycho.local.keepTarget
|
|
+ if ((System.getProperty("TYCHO_MVN_LOCAL") == null && System.getProperty("TYCHO_MVN_RPMBUILD") == null)
|
|
+ || System.getProperty("tycho.local.keepTarget") != null) {
|
|
+ addTargetEnvironments(result, project, configuration);
|
|
+ }
|
|
|
|
setTargetPlatformResolver(result, configuration);
|
|
|
|
diff --git a/tycho-p2/tycho-p2-facade/pom.xml b/tycho-p2/tycho-p2-facade/pom.xml
|
|
index dc1941f..0e84b5b 100644
|
|
--- a/tycho-p2/tycho-p2-facade/pom.xml
|
|
+++ b/tycho-p2/tycho-p2-facade/pom.xml
|
|
@@ -57,6 +57,11 @@
|
|
<artifactId>junit</artifactId>
|
|
<scope>test</scope>
|
|
</dependency>
|
|
+ <dependency>
|
|
+ <groupId>org.fedoraproject.p2</groupId>
|
|
+ <artifactId>org.fedoraproject.p2</artifactId>
|
|
+ <version>0.0.1-SNAPSHOT</version>
|
|
+ </dependency>
|
|
</dependencies>
|
|
|
|
<build>
|
|
diff --git a/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2DependencyResolver.java b/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2DependencyResolver.java
|
|
index 255df24..2e4e113 100644
|
|
--- a/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2DependencyResolver.java
|
|
+++ b/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2DependencyResolver.java
|
|
@@ -15,6 +15,7 @@ import java.net.MalformedURLException;
|
|
import java.net.URI;
|
|
import java.net.URISyntaxException;
|
|
import java.net.URL;
|
|
+import java.nio.file.Paths;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
@@ -85,6 +86,7 @@ import org.eclipse.tycho.p2.resolver.facade.P2ResolverFactory;
|
|
import org.eclipse.tycho.p2.target.facade.PomDependencyCollector;
|
|
import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub;
|
|
import org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade;
|
|
+import org.fedoraproject.p2.EclipseSystemLayout;
|
|
|
|
@Component(role = DependencyResolver.class, hint = P2DependencyResolver.ROLE_HINT, instantiationStrategy = "per-lookup")
|
|
public class P2DependencyResolver extends AbstractLogEnabled implements DependencyResolver, Initializable {
|
|
@@ -201,6 +203,34 @@ public class P2DependencyResolver extends AbstractLogEnabled implements Dependen
|
|
pomDependencies.setProjectLocation(project.getBasedir());
|
|
}
|
|
|
|
+ // Add Fedora Local P2 Repository when running in local mode
|
|
+ if (System.getProperty("TYCHO_MVN_LOCAL") != null || System.getProperty("TYCHO_MVN_RPMBUILD") != null) {
|
|
+
|
|
+ Set<String> allLocations = new HashSet<String>();
|
|
+ final Set<String> roots = EclipseSystemLayout.getSCLRoots();
|
|
+
|
|
+ Set<String> platformDirs = new HashSet<String>();
|
|
+ Set<String> internalDirs = new HashSet<String>();
|
|
+ Set<String> externalDirs = new HashSet<String>();
|
|
+ for (String root : roots) {
|
|
+ EclipseSystemLayout.initLocations(Paths.get(root), platformDirs, internalDirs, externalDirs, false);
|
|
+ }
|
|
+
|
|
+ allLocations.addAll(platformDirs);
|
|
+ allLocations.addAll(internalDirs);
|
|
+ allLocations.addAll(externalDirs);
|
|
+ allLocations.addAll(EclipseSystemLayout.getUserDefinedBundleLocations());
|
|
+
|
|
+ for (String loc : allLocations) {
|
|
+ String uri = "fedora:" + loc;
|
|
+ try {
|
|
+ tpConfiguration.addP2Repository(new MavenRepositoryLocation(uri, new URI(uri)));
|
|
+ } catch (URISyntaxException e) {
|
|
+ getLogger().warn("Unable to resolve repository URI : " + uri, e);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
for (ArtifactRepository repository : project.getRemoteArtifactRepositories()) {
|
|
addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration);
|
|
}
|
|
--
|
|
1.8.3.1
|
|
|