Blame SOURCES/0003-Tycho-should-always-delegate-artifact-resolution-to-.patch

84bf7c
From 2e005b107e6abda5bf09a963a54833cedabfba99 Mon Sep 17 00:00:00 2001
84bf7c
From: Roland Grunberg <rgrunber@redhat.com>
84bf7c
Date: Wed, 18 Jun 2014 13:01:31 -0400
84bf7c
Subject: [PATCH 3/6] Tycho should always delegate artifact resolution to
84bf7c
 Maven.
84bf7c
84bf7c
Maven resolves dependencies from the following locations in the
84bf7c
following order:
84bf7c
    * reactor,
84bf7c
    * workspace (eg. XMvn),
84bf7c
    * local repository,
84bf7c
    * remote repositories.
84bf7c
84bf7c
Tycho assumes that all resolved artifacts are present within the reactor
84bf7c
cache but this is not true for artifacts resolved from workspace
84bf7c
locations.
84bf7c
84bf7c
Change-Id: Ia44969ed1064965a82c3507a63e54caeebb75b18
84bf7c
---
84bf7c
 .../META-INF/MANIFEST.MF                      |  1 +
84bf7c
 .../tycho/core/shared/MavenContext.java       |  2 +
84bf7c
 .../tycho/core/shared/MavenContextImpl.java   | 10 +++-
84bf7c
 .../core/shared/MavenRepositorySystem.java    | 19 +++++++
84bf7c
 .../LocalArtifactRepositoryP2APITest.java     |  4 +-
84bf7c
 .../local/LocalMetadataRepositoryTest.java    |  3 +-
84bf7c
 .../local/LocalArtifactRepository.java        |  8 +--
84bf7c
 .../local/LocalArtifactRepositoryFactory.java |  3 +-
84bf7c
 .../index/LocalRepositoryP2IndicesImpl.java   |  7 +++
84bf7c
 .../remote/RemoteAgentMavenMirrorsTest.java   |  3 +-
84bf7c
 ...emoteAgentMetadataRepositoryCacheTest.java |  5 +-
84bf7c
 .../TargetPlatformBundlePublisherTest.java    |  3 +-
84bf7c
 .../tycho/p2/target/TestResolverFactory.java  |  5 +-
84bf7c
 .../p2/resolver/P2ResolverFactoryImpl.java    |  8 +--
84bf7c
 .../p2/target/PomDependencyCollectorImpl.java |  2 +-
84bf7c
 .../target/TargetPlatformBundlePublisher.java | 13 +++--
84bf7c
 .../repository/LocalRepositoryP2Indices.java  |  4 ++
84bf7c
 .../p2/repository/LocalRepositoryReader.java  | 49 +++++--------------
84bf7c
 .../TemporaryLocalMavenRepository.java        |  4 +-
84bf7c
 .../test/util/MavenRepositorySystemStub.java  | 30 ++++++++++++
84bf7c
 .../MavenRepositorySystemAdapter.java         | 37 ++++++++++++++
84bf7c
 .../MavenContextConfigurator.java             |  8 ++-
84bf7c
 22 files changed, 166 insertions(+), 62 deletions(-)
84bf7c
 create mode 100644 tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenRepositorySystem.java
84bf7c
 create mode 100644 tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/test/util/MavenRepositorySystemStub.java
84bf7c
 create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/osgi/adapters/MavenRepositorySystemAdapter.java
84bf7c
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared.tests/META-INF/MANIFEST.MF b/tycho-bundles/org.eclipse.tycho.core.shared.tests/META-INF/MANIFEST.MF
84bf7c
index ef464f8..05ac727 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.core.shared.tests/META-INF/MANIFEST.MF
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.core.shared.tests/META-INF/MANIFEST.MF
84bf7c
@@ -8,3 +8,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.8
84bf7c
 Require-Bundle: org.junit;bundle-version="4.8.2"
84bf7c
 Bundle-Vendor: %providerName
84bf7c
 Automatic-Module-Name: org.eclipse.tycho.core.shared.tests
84bf7c
+Import-Package: org.eclipse.tycho.p2.repository
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContext.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContext.java
84bf7c
index d63c1f1..cd8594d 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContext.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContext.java
84bf7c
@@ -38,4 +38,6 @@ public interface MavenContext {
84bf7c
      */
84bf7c
     public Properties getSessionProperties();
84bf7c
 
84bf7c
+    public MavenRepositorySystem getRepositorySystem();
84bf7c
+
84bf7c
 }
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContextImpl.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContextImpl.java
84bf7c
index d9f7bc6..683772c 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContextImpl.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenContextImpl.java
84bf7c
@@ -19,18 +19,20 @@ public class MavenContextImpl implements MavenContext {
84bf7c
     private MavenLogger mavenLogger;
84bf7c
     private boolean offline;
84bf7c
     private Properties mergedProperties;
84bf7c
+    private MavenRepositorySystem repositorySystem;
84bf7c
 
84bf7c
     public MavenContextImpl(File localRepositoryRoot, boolean offline, MavenLogger mavenLogger,
84bf7c
-            Properties mergedProperties) {
84bf7c
+            Properties mergedProperties, MavenRepositorySystem repositorySystem) {
84bf7c
         this.localRepositoryRoot = localRepositoryRoot;
84bf7c
         this.offline = offline;
84bf7c
         this.mavenLogger = mavenLogger;
84bf7c
         this.mergedProperties = mergedProperties;
84bf7c
+        this.repositorySystem = repositorySystem;
84bf7c
     }
84bf7c
 
84bf7c
     // constructor for tests
84bf7c
     public MavenContextImpl(File localRepositoryRoot, MavenLogger mavenLogger) {
84bf7c
-        this(localRepositoryRoot, false, mavenLogger, new Properties());
84bf7c
+        this(localRepositoryRoot, false, mavenLogger, new Properties(), null);
84bf7c
     }
84bf7c
 
84bf7c
     @Override
84bf7c
@@ -53,4 +55,8 @@ public class MavenContextImpl implements MavenContext {
84bf7c
         return mergedProperties;
84bf7c
     }
84bf7c
 
84bf7c
+    public MavenRepositorySystem getRepositorySystem() {
84bf7c
+        return repositorySystem;
84bf7c
+    }
84bf7c
+
84bf7c
 }
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenRepositorySystem.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenRepositorySystem.java
84bf7c
new file mode 100644
84bf7c
index 0000000..965e5cd
84bf7c
--- /dev/null
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/shared/MavenRepositorySystem.java
84bf7c
@@ -0,0 +1,19 @@
84bf7c
+/*******************************************************************************
84bf7c
+ * Copyright (c) 2014 Red Hat Inc.
84bf7c
+ * All rights reserved. This program and the accompanying materials
84bf7c
+ * are made available under the terms of the Eclipse Public License v1.0
84bf7c
+ * which accompanies this distribution, and is available at
84bf7c
+ * http://www.eclipse.org/legal/epl-v10.html
84bf7c
+ *
84bf7c
+ * Contributors:
84bf7c
+ *     Red Hat Inc. - initial API and implementation
84bf7c
+ *******************************************************************************/
84bf7c
+package org.eclipse.tycho.core.shared;
84bf7c
+
84bf7c
+import java.io.File;
84bf7c
+
84bf7c
+public interface MavenRepositorySystem {
84bf7c
+
84bf7c
+    public File resolve(String gid, String aid, String version, String type, String classifier);
84bf7c
+
84bf7c
+}
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryP2APITest.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryP2APITest.java
84bf7c
index 7bf376b..781b53f 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryP2APITest.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryP2APITest.java
84bf7c
@@ -53,6 +53,7 @@ import org.eclipse.tycho.repository.p2base.artifact.repository.ArtifactRepositor
84bf7c
 import org.eclipse.tycho.repository.streaming.testutil.ProbeArtifactSink;
84bf7c
 import org.eclipse.tycho.repository.streaming.testutil.ProbeOutputStream;
84bf7c
 import org.eclipse.tycho.repository.streaming.testutil.ProbeRawArtifactSink;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.junit.After;
84bf7c
 import org.junit.Before;
84bf7c
 import org.junit.Rule;
84bf7c
@@ -114,7 +115,8 @@ public class LocalArtifactRepositoryP2APITest {
84bf7c
     @Before
84bf7c
     public void initSubject() throws Exception {
84bf7c
         temporaryLocalMavenRepo.initContentFromResourceFolder(ResourceUtil.resourceFile("repositories/local"));
84bf7c
-        subject = new LocalArtifactRepository(null, temporaryLocalMavenRepo.getLocalRepositoryIndex());
84bf7c
+        subject = new LocalArtifactRepository(null, temporaryLocalMavenRepo.getLocalRepositoryIndex(),
84bf7c
+                new MavenRepositorySystemStub(temporaryLocalMavenRepo.getLocalRepositoryRoot()));
84bf7c
 
84bf7c
         testOutputStream = new ProbeOutputStream();
84bf7c
     }
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalMetadataRepositoryTest.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalMetadataRepositoryTest.java
84bf7c
index 1695b0f..52ac568 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalMetadataRepositoryTest.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalMetadataRepositoryTest.java
84bf7c
@@ -30,6 +30,7 @@ import org.eclipse.tycho.p2.repository.LocalRepositoryReader;
84bf7c
 import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
84bf7c
 import org.eclipse.tycho.p2.repository.TychoRepositoryIndex;
84bf7c
 import org.eclipse.tycho.repository.local.index.FileBasedTychoRepositoryIndex;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.junit.Assert;
84bf7c
 import org.junit.Test;
84bf7c
 
84bf7c
@@ -47,7 +48,7 @@ public class LocalMetadataRepositoryTest extends BaseMavenRepositoryTest {
84bf7c
 
84bf7c
     protected IMetadataRepository loadRepository(File location) throws ProvisionException {
84bf7c
         return new LocalMetadataRepository(location.toURI(), createMetadataIndex(location),
84bf7c
-                new LocalRepositoryReader(location));
84bf7c
+                new LocalRepositoryReader(location, new MavenRepositorySystemStub(location)));
84bf7c
     }
84bf7c
 
84bf7c
     private LocalMetadataRepository createRepository(File location) throws ProvisionException {
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepository.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepository.java
84bf7c
index 6e45753..406c1dc 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepository.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepository.java
84bf7c
@@ -23,6 +23,7 @@ import java.util.Set;
84bf7c
 import org.eclipse.equinox.p2.core.IProvisioningAgent;
84bf7c
 import org.eclipse.equinox.p2.metadata.IArtifactKey;
84bf7c
 import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
 import org.eclipse.tycho.p2.maven.repository.Activator;
84bf7c
 import org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO;
84bf7c
 import org.eclipse.tycho.p2.repository.GAV;
84bf7c
@@ -42,15 +43,16 @@ public class LocalArtifactRepository extends ArtifactRepositoryBaseImpl
84bf7c
 
84bf7c
     // TODO what is the agent needed for? does using the default agent harm?
84bf7c
     public LocalArtifactRepository(LocalRepositoryP2Indices localRepoIndices) {
84bf7c
-        this(Activator.getProvisioningAgent(), localRepoIndices);
84bf7c
+        this(Activator.getProvisioningAgent(), localRepoIndices, (MavenRepositorySystem) null);
84bf7c
     }
84bf7c
 
84bf7c
     public LocalArtifactRepository(LocalRepositoryP2Indices localRepoIndices, RepositoryReader contentLocator) {
84bf7c
         this(Activator.getProvisioningAgent(), localRepoIndices, contentLocator);
84bf7c
     }
84bf7c
 
84bf7c
-    public LocalArtifactRepository(IProvisioningAgent agent, LocalRepositoryP2Indices localRepoIndices) {
84bf7c
-        this(agent, localRepoIndices, new LocalRepositoryReader(localRepoIndices.getBasedir()));
84bf7c
+    public LocalArtifactRepository(IProvisioningAgent agent, LocalRepositoryP2Indices localRepoIndices,
84bf7c
+            MavenRepositorySystem repositorySystem) {
84bf7c
+        this(agent, localRepoIndices, new LocalRepositoryReader(localRepoIndices.getBasedir(), repositorySystem));
84bf7c
     }
84bf7c
 
84bf7c
     public LocalArtifactRepository(IProvisioningAgent agent, LocalRepositoryP2Indices localRepoIndices,
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryFactory.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryFactory.java
84bf7c
index 8356f46..34ac8fc 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryFactory.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalArtifactRepositoryFactory.java
84bf7c
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
84bf7c
 import org.eclipse.equinox.p2.core.ProvisionException;
84bf7c
 import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
84bf7c
 import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactRepositoryFactory;
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
 import org.eclipse.tycho.p2.maven.repository.Activator;
84bf7c
 import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices;
84bf7c
 import org.eclipse.tycho.repository.util.internal.RepositoryFactoryTools;
84bf7c
@@ -41,7 +42,7 @@ public class LocalArtifactRepositoryFactory extends ArtifactRepositoryFactory {
84bf7c
             if (localRepositoryDirectory.isDirectory()
84bf7c
                     && new File(localRepositoryDirectory, ".meta/p2-artifacts.properties").exists()) {
84bf7c
                 // see FileBasedTychoRepositoryIndex#ARTIFACTS_INDEX_RELPATH
84bf7c
-                return new LocalArtifactRepository(getAgent(), lookupLocalRepoIndices());
84bf7c
+                return new LocalArtifactRepository(getAgent(), lookupLocalRepoIndices(), lookupLocalRepoIndices().getRepositorySystem());
84bf7c
             }
84bf7c
         }
84bf7c
         return null;
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/index/LocalRepositoryP2IndicesImpl.java b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/index/LocalRepositoryP2IndicesImpl.java
84bf7c
index ccc9f64..7f06ecd 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/index/LocalRepositoryP2IndicesImpl.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/index/LocalRepositoryP2IndicesImpl.java
84bf7c
@@ -15,6 +15,7 @@ import java.io.File;
84bf7c
 
84bf7c
 import org.eclipse.tycho.core.shared.MavenContext;
84bf7c
 import org.eclipse.tycho.core.shared.MavenLogger;
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
 import org.eclipse.tycho.locking.facade.FileLockService;
84bf7c
 import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices;
84bf7c
 import org.eclipse.tycho.p2.repository.TychoRepositoryIndex;
84bf7c
@@ -25,6 +26,7 @@ public class LocalRepositoryP2IndicesImpl implements LocalRepositoryP2Indices {
84bf7c
     private FileLockService fileLockService;
84bf7c
     private File localRepositoryRoot;
84bf7c
     private MavenLogger logger;
84bf7c
+    private MavenRepositorySystem repoSystem;
84bf7c
 
84bf7c
     // derived members
84bf7c
     private boolean initialized = false;
84bf7c
@@ -39,6 +41,7 @@ public class LocalRepositoryP2IndicesImpl implements LocalRepositoryP2Indices {
84bf7c
     public void setMavenContext(MavenContext mavenContext) {
84bf7c
         this.localRepositoryRoot = mavenContext.getLocalRepositoryRoot();
84bf7c
         this.logger = mavenContext.getLogger();
84bf7c
+        this.repoSystem = mavenContext.getRepositorySystem();
84bf7c
     }
84bf7c
 
84bf7c
     // injected by DS runtime
84bf7c
@@ -80,4 +83,8 @@ public class LocalRepositoryP2IndicesImpl implements LocalRepositoryP2Indices {
84bf7c
         return localRepositoryRoot;
84bf7c
     }
84bf7c
 
84bf7c
+    public MavenRepositorySystem getRepositorySystem() {
84bf7c
+        return repoSystem;
84bf7c
+    }
84bf7c
+
84bf7c
 }
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMavenMirrorsTest.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMavenMirrorsTest.java
84bf7c
index 432ec09..4e5566a 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMavenMirrorsTest.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMavenMirrorsTest.java
84bf7c
@@ -29,6 +29,7 @@ import org.eclipse.tycho.p2.impl.test.ResourceUtil;
84bf7c
 import org.eclipse.tycho.p2.remote.testutil.MavenRepositorySettingsStub;
84bf7c
 import org.eclipse.tycho.test.util.HttpServer;
84bf7c
 import org.eclipse.tycho.test.util.LogVerifier;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.junit.Before;
84bf7c
 import org.junit.Rule;
84bf7c
 import org.junit.Test;
84bf7c
@@ -52,7 +53,7 @@ public class RemoteAgentMavenMirrorsTest {
84bf7c
     public void initSubject() throws Exception {
84bf7c
         File localRepository = tempManager.newFolder("localRepo");
84bf7c
         MavenContext mavenContext = new MavenContextImpl(localRepository, OFFLINE, logVerifier.getLogger(),
84bf7c
-                new Properties());
84bf7c
+                new Properties(), new MavenRepositorySystemStub(localRepository));
84bf7c
 
84bf7c
         mavenRepositorySettings = new MavenRepositorySettingsStub();
84bf7c
         subject = new RemoteAgent(mavenContext, mavenRepositorySettings, OFFLINE);
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMetadataRepositoryCacheTest.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMetadataRepositoryCacheTest.java
84bf7c
index ae31862..14b8f85 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMetadataRepositoryCacheTest.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/remote/RemoteAgentMetadataRepositoryCacheTest.java
84bf7c
@@ -26,6 +26,7 @@ import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
84bf7c
 import org.eclipse.tycho.core.shared.MavenContextImpl;
84bf7c
 import org.eclipse.tycho.test.util.HttpServer;
84bf7c
 import org.eclipse.tycho.test.util.LogVerifier;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.junit.Before;
84bf7c
 import org.junit.Rule;
84bf7c
 import org.junit.Test;
84bf7c
@@ -126,12 +127,12 @@ public class RemoteAgentMetadataRepositoryCacheTest {
84bf7c
 
84bf7c
     private RemoteAgent newOnlineAgent() throws Exception {
84bf7c
         return new RemoteAgent(new MavenContextImpl(localMavenRepository, false, logVerifier.getLogger(),
84bf7c
-                new Properties()));
84bf7c
+                new Properties(), new MavenRepositorySystemStub(localMavenRepository)));
84bf7c
     }
84bf7c
 
84bf7c
     private RemoteAgent newOfflineAgent() throws Exception {
84bf7c
         return new RemoteAgent(new MavenContextImpl(localMavenRepository, true, logVerifier.getLogger(),
84bf7c
-                new Properties()));
84bf7c
+                new Properties(), new MavenRepositorySystemStub(localMavenRepository)));
84bf7c
     }
84bf7c
 
84bf7c
     private IMetadataRepository loadHttpRepository(RemoteAgent agent) throws ProvisionException {
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisherTest.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisherTest.java
84bf7c
index f4a356f..e332785 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisherTest.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisherTest.java
84bf7c
@@ -32,6 +32,7 @@ import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
84bf7c
 import org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactProvider;
84bf7c
 import org.eclipse.tycho.repository.streaming.testutil.ProbeRawArtifactSink;
84bf7c
 import org.eclipse.tycho.test.util.LogVerifier;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.junit.Before;
84bf7c
 import org.junit.Rule;
84bf7c
 import org.junit.Test;
84bf7c
@@ -57,7 +58,7 @@ public class TargetPlatformBundlePublisherTest {
84bf7c
         logVerifier.expectNoWarnings();
84bf7c
 
84bf7c
         localRepositoryRoot = tempFolder.getRoot();
84bf7c
-        subject = new TargetPlatformBundlePublisher(localRepositoryRoot, logVerifier.getLogger());
84bf7c
+        subject = new TargetPlatformBundlePublisher(localRepositoryRoot, logVerifier.getLogger(), new MavenRepositorySystemStub(localRepositoryRoot));
84bf7c
     }
84bf7c
 
84bf7c
     @Test
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TestResolverFactory.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TestResolverFactory.java
84bf7c
index 4b44fdd..342437b 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TestResolverFactory.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/target/TestResolverFactory.java
84bf7c
@@ -28,6 +28,7 @@ import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory;
84bf7c
 import org.eclipse.tycho.repository.local.LocalArtifactRepository;
84bf7c
 import org.eclipse.tycho.repository.local.LocalMetadataRepository;
84bf7c
 import org.eclipse.tycho.repository.local.index.LocalRepositoryP2IndicesImpl;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.eclipse.tycho.test.util.NoopFileLockService;
84bf7c
 
84bf7c
 public class TestResolverFactory implements P2ResolverFactory {
84bf7c
@@ -45,7 +46,7 @@ public class TestResolverFactory implements P2ResolverFactory {
84bf7c
 
84bf7c
         File localMavenRepoRoot = mavenContext.getLocalRepositoryRoot();
84bf7c
         LocalRepositoryP2Indices localRepoIndices = createLocalRepoIndices(mavenContext);
84bf7c
-        LocalRepositoryReader localRepositoryReader = new LocalRepositoryReader(localMavenRepoRoot);
84bf7c
+        LocalRepositoryReader localRepositoryReader = new LocalRepositoryReader(localMavenRepoRoot, mavenContext.getRepositorySystem());
84bf7c
         localMetadataRepo = new LocalMetadataRepository(localMavenRepoRoot.toURI(),
84bf7c
                 localRepoIndices.getMetadataIndex(), localRepositoryReader);
84bf7c
         localArtifactRepo = new LocalArtifactRepository(localRepoIndices, localRepositoryReader);
84bf7c
@@ -56,7 +57,7 @@ public class TestResolverFactory implements P2ResolverFactory {
84bf7c
     }
84bf7c
 
84bf7c
     private MavenContext createMavenContext(boolean offline, MavenLogger logger) {
84bf7c
-        return new MavenContextImpl(getLocalRepositoryLocation(), offline, logger, new Properties());
84bf7c
+        return new MavenContextImpl(getLocalRepositoryLocation(), offline, logger, new Properties(), new MavenRepositorySystemStub(getLocalRepositoryLocation()));
84bf7c
     }
84bf7c
 
84bf7c
     // TODO use TemporaryLocalMavenRepository
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/P2ResolverFactoryImpl.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/P2ResolverFactoryImpl.java
84bf7c
index 1e6050c..2fee3b2 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/P2ResolverFactoryImpl.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/resolver/P2ResolverFactoryImpl.java
84bf7c
@@ -33,7 +33,7 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory {
84bf7c
     private static LocalMetadataRepository localMetadataRepository;
84bf7c
     private static LocalArtifactRepository localArtifactRepository;
84bf7c
 
84bf7c
-    private MavenContext mavenContext;
84bf7c
+    private static MavenContext mavenContext;
84bf7c
     private LocalRepositoryP2Indices localRepoIndices;
84bf7c
     private RemoteAgentManager remoteAgentManager;
84bf7c
     private TargetDefinitionResolverService targetDefinitionResolverService;
84bf7c
@@ -42,7 +42,8 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory {
84bf7c
             LocalRepositoryP2Indices localRepoIndices) {
84bf7c
         if (localMetadataRepository == null) {
84bf7c
             File localMavenRepoRoot = context.getLocalRepositoryRoot();
84bf7c
-            RepositoryReader contentLocator = new LocalRepositoryReader(localMavenRepoRoot);
84bf7c
+            RepositoryReader contentLocator = new LocalRepositoryReader(localMavenRepoRoot,
84bf7c
+                    mavenContext.getRepositorySystem());
84bf7c
             localMetadataRepository = new LocalMetadataRepository(localMavenRepoRoot.toURI(),
84bf7c
                     localRepoIndices.getMetadataIndex(), contentLocator);
84bf7c
 
84bf7c
@@ -53,7 +54,8 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory {
84bf7c
     private static synchronized LocalArtifactRepository getLocalArtifactRepository(MavenContext mavenContext,
84bf7c
             LocalRepositoryP2Indices localRepoIndices) {
84bf7c
         if (localArtifactRepository == null) {
84bf7c
-            RepositoryReader contentLocator = new LocalRepositoryReader(mavenContext.getLocalRepositoryRoot());
84bf7c
+            RepositoryReader contentLocator = new LocalRepositoryReader(mavenContext.getLocalRepositoryRoot(),
84bf7c
+                    mavenContext.getRepositorySystem());
84bf7c
             localArtifactRepository = new LocalArtifactRepository(localRepoIndices, contentLocator);
84bf7c
         }
84bf7c
         return localArtifactRepository;
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/PomDependencyCollectorImpl.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/PomDependencyCollectorImpl.java
84bf7c
index c7eabd1..6821461 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/PomDependencyCollectorImpl.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/PomDependencyCollectorImpl.java
84bf7c
@@ -44,7 +44,7 @@ public class PomDependencyCollectorImpl implements PomDependencyCollector {
84bf7c
         this.logger = mavenContext.getLogger();
84bf7c
 
84bf7c
         File localRepositoryRoot = mavenContext.getLocalRepositoryRoot();
84bf7c
-        this.bundlesPublisher = new TargetPlatformBundlePublisher(localRepositoryRoot, mavenContext.getLogger());
84bf7c
+        this.bundlesPublisher = new TargetPlatformBundlePublisher(localRepositoryRoot, mavenContext.getLogger(), mavenContext.getRepositorySystem());
84bf7c
     }
84bf7c
 
84bf7c
     @Override
84bf7c
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
84bf7c
index 0d15db9..a5f8822 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisher.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBundlePublisher.java
84bf7c
@@ -25,6 +25,7 @@ import org.eclipse.equinox.p2.publisher.PublisherResult;
84bf7c
 import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
84bf7c
 import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
84bf7c
 import org.eclipse.tycho.core.shared.MavenLogger;
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
 import org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice;
84bf7c
 import org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository;
84bf7c
 import org.eclipse.tycho.p2.metadata.IArtifactFacade;
84bf7c
@@ -42,8 +43,9 @@ public class TargetPlatformBundlePublisher {
84bf7c
     private final MavenLogger logger;
84bf7c
     private final PublishedBundlesArtifactRepository publishedArtifacts;
84bf7c
 
84bf7c
-    public TargetPlatformBundlePublisher(File localMavenRepositoryRoot, MavenLogger logger) {
84bf7c
-        this.publishedArtifacts = new PublishedBundlesArtifactRepository(localMavenRepositoryRoot);
84bf7c
+    public TargetPlatformBundlePublisher(File localMavenRepositoryRoot, MavenLogger logger,
84bf7c
+            MavenRepositorySystem repositorySystem) {
84bf7c
+        this.publishedArtifacts = new PublishedBundlesArtifactRepository(localMavenRepositoryRoot, repositorySystem);
84bf7c
         this.logger = logger;
84bf7c
     }
84bf7c
 
84bf7c
@@ -204,8 +206,11 @@ public class TargetPlatformBundlePublisher {
84bf7c
      */
84bf7c
     private static class PublishedBundlesArtifactRepository extends ArtifactRepositoryBaseImpl<GAVArtifactDescriptor> {
84bf7c
 
84bf7c
-        PublishedBundlesArtifactRepository(File localMavenRepositoryRoot) {
84bf7c
+        private MavenRepositorySystem repositorySystem;
84bf7c
+
84bf7c
+        PublishedBundlesArtifactRepository(File localMavenRepositoryRoot, MavenRepositorySystem repositorySystem) {
84bf7c
             super(null, localMavenRepositoryRoot.toURI(), ArtifactTransferPolicies.forLocalArtifacts());
84bf7c
+            this.repositorySystem = repositorySystem;
84bf7c
         }
84bf7c
 
84bf7c
         void addPublishedArtifact(IArtifactDescriptor baseDescriptor, IArtifactFacade mavenArtifact) {
84bf7c
@@ -250,7 +255,7 @@ public class TargetPlatformBundlePublisher {
84bf7c
         @Override
84bf7c
         protected File internalGetArtifactStorageLocation(IArtifactDescriptor descriptor) {
84bf7c
             MavenRepositoryCoordinates coord = toInternalDescriptor(descriptor).getMavenCoordinates();
84bf7c
-            LocalRepositoryReader reader = new LocalRepositoryReader(getBaseDir());
84bf7c
+            LocalRepositoryReader reader = new LocalRepositoryReader(getBaseDir(), repositorySystem);
84bf7c
             return reader.getLocalArtifactLocation(coord.getGav(), coord.getClassifier(), coord.getExtensionOrDefault());
84bf7c
         }
84bf7c
 
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryP2Indices.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryP2Indices.java
84bf7c
index 2122578..5e4a01e 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryP2Indices.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryP2Indices.java
84bf7c
@@ -13,6 +13,8 @@ package org.eclipse.tycho.p2.repository;
84bf7c
 
84bf7c
 import java.io.File;
84bf7c
 
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
+
84bf7c
 /**
84bf7c
  * This service provides access to the tycho p2 index files of the local maven repository.
84bf7c
  */
84bf7c
@@ -24,4 +26,6 @@ public interface LocalRepositoryP2Indices {
84bf7c
 
84bf7c
     public File getBasedir();
84bf7c
 
84bf7c
+    public MavenRepositorySystem getRepositorySystem();
84bf7c
+
84bf7c
 }
84bf7c
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
84bf7c
index 74b8028..1aeb3ac 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java
84bf7c
@@ -14,55 +14,28 @@ import java.io.File;
84bf7c
 import java.lang.reflect.Constructor;
84bf7c
 import java.lang.reflect.Method;
84bf7c
 
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
+
84bf7c
 public class LocalRepositoryReader implements RepositoryReader {
84bf7c
 
84bf7c
     private final File localMavenRepositoryRoot;
84bf7c
+    private final MavenRepositorySystem repositorySystem;
84bf7c
 
84bf7c
-    public LocalRepositoryReader(File localMavenRepositoryRoot) {
84bf7c
+    public LocalRepositoryReader(File localMavenRepositoryRoot, MavenRepositorySystem repositorySystem) {
84bf7c
         this.localMavenRepositoryRoot = localMavenRepositoryRoot;
84bf7c
+        this.repositorySystem = repositorySystem;
84bf7c
     }
84bf7c
 
84bf7c
     @Override
84bf7c
     @SuppressWarnings({ "unchecked", "rawtypes" })
84bf7c
     public File getLocalArtifactLocation(GAV gav, String classifier, String extension) {
84bf7c
-        File file = new File(localMavenRepositoryRoot, RepositoryLayoutHelper.getRelativePath(gav, classifier,
84bf7c
-                extension));
84bf7c
-        // In Fedora the artifact may be in an XMvn-defined repository location (not in reactor cache)
84bf7c
-        if (!file.exists()) {
84bf7c
-            try {
84bf7c
-                // Create Plexus config
84bf7c
-                Class pcclazz = Class.forName("org.codehaus.plexus.ContainerConfiguration");
84bf7c
-                Object conf = Class.forName("org.codehaus.plexus.DefaultContainerConfiguration").newInstance();
84bf7c
-                pcclazz.getMethod("setAutoWiring", boolean.class).invoke(conf, true);
84bf7c
-                pcclazz.getMethod("setClassPathScanning", String.class).invoke(conf, "index");
84bf7c
-
84bf7c
-                // Use plexus container to lookup the reader
84bf7c
-                Class pclazz = Class.forName("org.codehaus.plexus.DefaultPlexusContainer");
84bf7c
-                Object plexus = pclazz.getConstructor(pcclazz).newInstance(conf);
84bf7c
-
84bf7c
-                // Retrieve the workspace reader from the plexus container
84bf7c
-                Method mLookup = pclazz.getMethod("lookup", String.class, String.class);
84bf7c
-                Object reader = mLookup.invoke(plexus, "org.eclipse.aether.repository.WorkspaceReader", "ide");
84bf7c
-
84bf7c
-                // Create an Aether Artifact based on GAV, classifier, and extension
84bf7c
-                Class iartclazz = Class.forName("org.eclipse.aether.artifact.Artifact");
84bf7c
-                Class artclazz = Class.forName("org.eclipse.aether.artifact.DefaultArtifact");
84bf7c
-                Constructor cNew = artclazz.getConstructor(String.class, String.class, String.class, String.class,
84bf7c
-                        String.class);
84bf7c
-                Object artifact = cNew.newInstance(gav.getGroupId(), gav.getArtifactId(), classifier, extension,
84bf7c
-                        gav.getVersion());
84bf7c
-
84bf7c
-                // Invoke "findArtifact" method of the workspace reader on the artifact
84bf7c
-                Method mfindArtifact = reader.getClass().getMethod("findArtifact", iartclazz);
84bf7c
-                File newFile = (File) mfindArtifact.invoke(reader, artifact);
84bf7c
-                if (newFile != null) {
84bf7c
-                    file = newFile;
84bf7c
-                }
84bf7c
-            } catch (Exception e) {
84bf7c
-                e.printStackTrace();
84bf7c
+        File ret = new File(localMavenRepositoryRoot, RepositoryLayoutHelper.getRelativePath(gav, classifier, extension));
84bf7c
+        if (repositorySystem != null) {
84bf7c
+            File tmp = repositorySystem.resolve(gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), extension, classifier);
84bf7c
+            if (tmp != null) {
84bf7c
+                ret = tmp;
84bf7c
             }
84bf7c
         }
84bf7c
-        return file;
84bf7c
-
84bf7c
+        return ret;
84bf7c
     }
84bf7c
 }
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/TemporaryLocalMavenRepository.java b/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/TemporaryLocalMavenRepository.java
84bf7c
index 5c0bcb8..3d05393 100644
84bf7c
--- a/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/TemporaryLocalMavenRepository.java
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/TemporaryLocalMavenRepository.java
84bf7c
@@ -14,9 +14,11 @@ import java.io.File;
84bf7c
 import java.io.IOException;
84bf7c
 
84bf7c
 import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
 import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices;
84bf7c
 import org.eclipse.tycho.repository.local.LocalArtifactRepository;
84bf7c
 import org.eclipse.tycho.repository.local.index.LocalRepositoryP2IndicesImpl;
84bf7c
+import org.eclipse.tycho.test.util.MavenRepositorySystemStub;
84bf7c
 import org.eclipse.tycho.test.util.NoopFileLockService;
84bf7c
 import org.junit.Rule;
84bf7c
 import org.junit.rules.ExternalResource;
84bf7c
@@ -72,7 +74,7 @@ public class TemporaryLocalMavenRepository extends ExternalResource {
84bf7c
 
84bf7c
     public LocalArtifactRepository getLocalArtifactRepository() {
84bf7c
         if (repo == null) {
84bf7c
-            repo = new LocalArtifactRepository(null, getLocalRepositoryIndex());
84bf7c
+            repo = new LocalArtifactRepository(null, getLocalRepositoryIndex(), new MavenRepositorySystemStub(getLocalRepositoryRoot()));
84bf7c
         }
84bf7c
         return repo;
84bf7c
     }
84bf7c
diff --git a/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/test/util/MavenRepositorySystemStub.java b/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/test/util/MavenRepositorySystemStub.java
84bf7c
new file mode 100644
84bf7c
index 0000000..7e020da
84bf7c
--- /dev/null
84bf7c
+++ b/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/test/util/MavenRepositorySystemStub.java
84bf7c
@@ -0,0 +1,30 @@
84bf7c
+/*******************************************************************************
84bf7c
+ * Copyright (c) 2014 Red Hat Inc.
84bf7c
+ * All rights reserved. This program and the accompanying materials
84bf7c
+ * are made available under the terms of the Eclipse Public License v1.0
84bf7c
+ * which accompanies this distribution, and is available at
84bf7c
+ * http://www.eclipse.org/legal/epl-v10.html
84bf7c
+ *
84bf7c
+ * Contributors:
84bf7c
+ *     Red Hat Inc. - initial API and implementation
84bf7c
+ *******************************************************************************/
84bf7c
+package org.eclipse.tycho.test.util;
84bf7c
+
84bf7c
+import java.io.File;
84bf7c
+
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
+import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
84bf7c
+
84bf7c
+public class MavenRepositorySystemStub implements MavenRepositorySystem {
84bf7c
+
84bf7c
+    private File localMavenRepositoryRoot;
84bf7c
+
84bf7c
+    public MavenRepositorySystemStub(File localMavenRepositoryRoot) {
84bf7c
+        this.localMavenRepositoryRoot = localMavenRepositoryRoot;
84bf7c
+    }
84bf7c
+
84bf7c
+    public File resolve(String gid, String aid, String version, String type, String classifier) {
84bf7c
+        return new File(localMavenRepositoryRoot, RepositoryLayoutHelper.getRelativePath(gid, aid, version, classifier,
84bf7c
+                type));
84bf7c
+    }
84bf7c
+}
84bf7c
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/adapters/MavenRepositorySystemAdapter.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/adapters/MavenRepositorySystemAdapter.java
84bf7c
new file mode 100644
84bf7c
index 0000000..e1d46fa
84bf7c
--- /dev/null
84bf7c
+++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/adapters/MavenRepositorySystemAdapter.java
84bf7c
@@ -0,0 +1,37 @@
84bf7c
+/*******************************************************************************
84bf7c
+ * Copyright (c) 2014 Red Hat Inc.
84bf7c
+ * All rights reserved. This program and the accompanying materials
84bf7c
+ * are made available under the terms of the Eclipse Public License v1.0
84bf7c
+ * which accompanies this distribution, and is available at
84bf7c
+ * http://www.eclipse.org/legal/epl-v10.html
84bf7c
+ *
84bf7c
+ * Contributors:
84bf7c
+ *     Red Hat Inc. - initial API and implementation
84bf7c
+ *******************************************************************************/
84bf7c
+package org.eclipse.tycho.osgi.adapters;
84bf7c
+
84bf7c
+import java.io.File;
84bf7c
+
84bf7c
+import org.apache.maven.artifact.Artifact;
84bf7c
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
84bf7c
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
84bf7c
+import org.apache.maven.repository.RepositorySystem;
84bf7c
+import org.eclipse.tycho.core.shared.MavenRepositorySystem;
84bf7c
+
84bf7c
+public class MavenRepositorySystemAdapter implements MavenRepositorySystem {
84bf7c
+
84bf7c
+    private RepositorySystem repoSystem;
84bf7c
+
84bf7c
+    public MavenRepositorySystemAdapter(RepositorySystem repoSystem) {
84bf7c
+        this.repoSystem = repoSystem;
84bf7c
+    }
84bf7c
+
84bf7c
+    public File resolve(String gid, String aid, String version, String type, String classifier) {
84bf7c
+        ArtifactResolutionRequest req = new ArtifactResolutionRequest();
84bf7c
+        Artifact art = repoSystem.createArtifactWithClassifier(gid, aid, version, type, classifier);
84bf7c
+        req.setArtifact(art);
84bf7c
+        ArtifactResolutionResult res = repoSystem.resolve(req);
84bf7c
+        return res.getArtifacts().size() > 0 ? res.getArtifacts().toArray(new Artifact[0])[0].getFile() : null;
84bf7c
+    }
84bf7c
+
84bf7c
+}
84bf7c
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java
84bf7c
index e5837e2..137dcb1 100644
84bf7c
--- a/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java
84bf7c
+++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/configuration/MavenContextConfigurator.java
84bf7c
@@ -16,6 +16,7 @@ import java.util.Properties;
84bf7c
 
84bf7c
 import org.apache.maven.execution.MavenSession;
84bf7c
 import org.apache.maven.plugin.LegacySupport;
84bf7c
+import org.apache.maven.repository.RepositorySystem;
84bf7c
 import org.apache.maven.settings.Profile;
84bf7c
 import org.apache.maven.settings.Settings;
84bf7c
 import org.codehaus.plexus.component.annotations.Component;
84bf7c
@@ -26,6 +27,7 @@ import org.eclipse.sisu.equinox.embedder.EquinoxLifecycleListener;
84bf7c
 import org.eclipse.tycho.core.shared.MavenContext;
84bf7c
 import org.eclipse.tycho.core.shared.MavenContextImpl;
84bf7c
 import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter;
84bf7c
+import org.eclipse.tycho.osgi.adapters.MavenRepositorySystemAdapter;
84bf7c
 
84bf7c
 @Component(role = EquinoxLifecycleListener.class, hint = "MavenContextConfigurator")
84bf7c
 public class MavenContextConfigurator extends EquinoxLifecycleListener {
84bf7c
@@ -36,13 +38,17 @@ public class MavenContextConfigurator extends EquinoxLifecycleListener {
84bf7c
     @Requirement
84bf7c
     private LegacySupport context;
84bf7c
 
84bf7c
+    @Requirement
84bf7c
+    private RepositorySystem repositorySystem;
84bf7c
+
84bf7c
     @Override
84bf7c
     public void afterFrameworkStarted(EmbeddedEquinox framework) {
84bf7c
         MavenSession session = context.getSession();
84bf7c
         File localRepoRoot = new File(session.getLocalRepository().getBasedir());
84bf7c
         MavenLoggerAdapter mavenLogger = new MavenLoggerAdapter(logger, false);
84bf7c
         Properties globalProps = getGlobalProperties(session);
84bf7c
-        MavenContext mavenContext = new MavenContextImpl(localRepoRoot, session.isOffline(), mavenLogger, globalProps);
84bf7c
+        MavenContext mavenContext = new MavenContextImpl(localRepoRoot, session.isOffline(), mavenLogger, globalProps,
84bf7c
+                new MavenRepositorySystemAdapter(repositorySystem));
84bf7c
         framework.registerService(MavenContext.class, mavenContext);
84bf7c
     }
84bf7c
 
84bf7c
-- 
84bf7c
2.20.1
84bf7c