697 lines
42 KiB
Diff
697 lines
42 KiB
Diff
From 0a635ab621a72f9911d159e93cd18c92c4a27b8b Mon Sep 17 00:00:00 2001
|
|
From: Roland Grunberg <rgrunber@redhat.com>
|
|
Date: Wed, 18 Jun 2014 13:01:31 -0400
|
|
Subject: [PATCH] Tycho should always delegate artifact resolution to Maven.
|
|
|
|
Maven resolves dependencies from the following locations in the
|
|
following order:
|
|
* reactor,
|
|
* workspace (eg. XMvn),
|
|
* local repository,
|
|
* remote repositories.
|
|
|
|
Tycho assumes that all resolved artifacts are present within the reactor
|
|
cache but this is not true for artifacts resolved from workspace
|
|
locations.
|
|
|
|
Change-Id: Ib6453720b46f64ae87dfabf829df8fad38d0cedc
|
|
---
|
|
.../META-INF/MANIFEST.MF | 1 +
|
|
.../eclipse/tycho/core/facade/MavenContext.java | 2 +
|
|
.../tycho/core/facade/MavenContextImpl.java | 10 ++++-
|
|
.../tycho/core/facade/MavenRepositorySystem.java | 19 ++++++++
|
|
.../local/LocalArtifactRepositoryP2APITest.java | 4 +-
|
|
.../local/LocalMetadataRepositoryTest.java | 3 +-
|
|
.../repository/local/LocalArtifactRepository.java | 8 ++--
|
|
.../local/LocalArtifactRepositoryFactory.java | 3 +-
|
|
.../local/index/LocalRepositoryP2IndicesImpl.java | 7 +++
|
|
.../META-INF/MANIFEST.MF | 1 +
|
|
.../p2/remote/RemoteAgentMavenMirrorsTest.java | 3 +-
|
|
.../RemoteAgentMetadataRepositoryCacheTest.java | 5 ++-
|
|
.../target/TargetPlatformBundlePublisherTest.java | 3 +-
|
|
.../tycho/p2/target/TestResolverFactory.java | 5 ++-
|
|
.../p2/impl/resolver/P2ResolverFactoryImpl.java | 8 ++--
|
|
.../p2/target/PomDependencyCollectorImpl.java | 2 +-
|
|
.../p2/target/TargetPlatformBundlePublisher.java | 15 ++++---
|
|
.../p2/repository/LocalRepositoryP2Indices.java | 4 ++
|
|
.../tycho/p2/repository/LocalRepositoryReader.java | 52 +++-------------------
|
|
.../local/testutil/MavenRepositorySystemStub.java | 30 +++++++++++++
|
|
.../testutil/TemporaryLocalMavenRepository.java | 3 +-
|
|
.../adapters/MavenRepositorySystemAdapter.java | 37 +++++++++++++++
|
|
.../configuration/MavenContextConfigurator.java | 8 +++-
|
|
23 files changed, 163 insertions(+), 70 deletions(-)
|
|
create mode 100644 tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenRepositorySystem.java
|
|
create mode 100644 tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/MavenRepositorySystemStub.java
|
|
create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/osgi/adapters/MavenRepositorySystemAdapter.java
|
|
|
|
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
|
|
index 20b5257..82ba810 100644
|
|
--- 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
|
|
@@ -7,3 +7,4 @@ Fragment-Host: org.eclipse.tycho.core.shared
|
|
Bundle-RequiredExecutionEnvironment: J2SE-1.5
|
|
Require-Bundle: org.junit;bundle-version="4.8.2"
|
|
Bundle-Vendor: %providerName
|
|
+Import-Package: org.eclipse.tycho.p2.repository
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContext.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContext.java
|
|
index 3b0f3f4..7ce5afd 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContext.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContext.java
|
|
@@ -38,4 +38,6 @@ public interface MavenContext {
|
|
*/
|
|
public Properties getSessionProperties();
|
|
|
|
+ public MavenRepositorySystem getRepositorySystem();
|
|
+
|
|
}
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContextImpl.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContextImpl.java
|
|
index 44b0e77..934e890 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContextImpl.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenContextImpl.java
|
|
@@ -19,18 +19,20 @@ public class MavenContextImpl implements MavenContext {
|
|
private MavenLogger mavenLogger;
|
|
private boolean offline;
|
|
private Properties mergedProperties;
|
|
+ private MavenRepositorySystem repositorySystem;
|
|
|
|
public MavenContextImpl(File localRepositoryRoot, boolean offline, MavenLogger mavenLogger,
|
|
- Properties mergedProperties) {
|
|
+ Properties mergedProperties, MavenRepositorySystem repositorySystem) {
|
|
this.localRepositoryRoot = localRepositoryRoot;
|
|
this.offline = offline;
|
|
this.mavenLogger = mavenLogger;
|
|
this.mergedProperties = mergedProperties;
|
|
+ this.repositorySystem = repositorySystem;
|
|
}
|
|
|
|
// constructor for tests
|
|
public MavenContextImpl(File localRepositoryRoot, MavenLogger mavenLogger) {
|
|
- this(localRepositoryRoot, false, mavenLogger, new Properties());
|
|
+ this(localRepositoryRoot, false, mavenLogger, new Properties(), null);
|
|
}
|
|
|
|
public File getLocalRepositoryRoot() {
|
|
@@ -49,4 +51,8 @@ public class MavenContextImpl implements MavenContext {
|
|
return mergedProperties;
|
|
}
|
|
|
|
+ public MavenRepositorySystem getRepositorySystem() {
|
|
+ return repositorySystem;
|
|
+ }
|
|
+
|
|
}
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenRepositorySystem.java b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenRepositorySystem.java
|
|
new file mode 100644
|
|
index 0000000..fd2f0a9
|
|
--- /dev/null
|
|
+++ b/tycho-bundles/org.eclipse.tycho.core.shared/src/main/java/org/eclipse/tycho/core/facade/MavenRepositorySystem.java
|
|
@@ -0,0 +1,19 @@
|
|
+/*******************************************************************************
|
|
+ * Copyright (c) 2014 Red Hat Inc.
|
|
+ * All rights reserved. This program and the accompanying materials
|
|
+ * are made available under the terms of the Eclipse Public License v1.0
|
|
+ * which accompanies this distribution, and is available at
|
|
+ * http://www.eclipse.org/legal/epl-v10.html
|
|
+ *
|
|
+ * Contributors:
|
|
+ * Red Hat Inc. - initial API and implementation
|
|
+ *******************************************************************************/
|
|
+package org.eclipse.tycho.core.facade;
|
|
+
|
|
+import java.io.File;
|
|
+
|
|
+public interface MavenRepositorySystem {
|
|
+
|
|
+ public File resolve(String gid, String aid, String version, String type, String classifier);
|
|
+
|
|
+}
|
|
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
|
|
index bedc5cb..659a015 100644
|
|
--- 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
|
|
@@ -44,6 +44,7 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
|
|
import org.eclipse.equinox.p2.repository.artifact.spi.ProcessingStepDescriptor;
|
|
import org.eclipse.tycho.p2.maven.repository.tests.ResourceUtil;
|
|
import org.eclipse.tycho.p2.maven.repository.tests.TestRepositoryContent;
|
|
+import org.eclipse.tycho.repository.local.testutil.MavenRepositorySystemStub;
|
|
import org.eclipse.tycho.repository.local.testutil.TemporaryLocalMavenRepository;
|
|
import org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider;
|
|
import org.eclipse.tycho.repository.p2base.artifact.provider.streaming.ArtifactSinkException;
|
|
@@ -114,7 +115,8 @@ public class LocalArtifactRepositoryP2APITest {
|
|
@Before
|
|
public void initSubject() throws Exception {
|
|
temporaryLocalMavenRepo.initContentFromResourceFolder(ResourceUtil.resourceFile("repositories/local"));
|
|
- subject = new LocalArtifactRepository(null, temporaryLocalMavenRepo.getLocalRepositoryIndex());
|
|
+ subject = new LocalArtifactRepository(null, temporaryLocalMavenRepo.getLocalRepositoryIndex(),
|
|
+ new MavenRepositorySystemStub(temporaryLocalMavenRepo.getLocalRepositoryRoot()));
|
|
|
|
testOutputStream = new ProbeOutputStream();
|
|
}
|
|
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
|
|
index 9b6d270..39d6ffd 100644
|
|
--- 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
|
|
@@ -32,6 +32,7 @@ import org.eclipse.tycho.p2.repository.LocalRepositoryReader;
|
|
import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
|
|
import org.eclipse.tycho.p2.repository.TychoRepositoryIndex;
|
|
import org.eclipse.tycho.repository.local.index.FileBasedTychoRepositoryIndex;
|
|
+import org.eclipse.tycho.repository.local.testutil.MavenRepositorySystemStub;
|
|
import org.junit.Test;
|
|
|
|
public class LocalMetadataRepositoryTest extends BaseMavenRepositoryTest {
|
|
@@ -48,7 +49,7 @@ public class LocalMetadataRepositoryTest extends BaseMavenRepositoryTest {
|
|
|
|
protected IMetadataRepository loadRepository(File location) throws ProvisionException {
|
|
return new LocalMetadataRepository(location.toURI(), createMetadataIndex(location), new LocalRepositoryReader(
|
|
- location));
|
|
+ location, new MavenRepositorySystemStub(tempLocalMavenRepository.getLocalRepositoryRoot())));
|
|
}
|
|
|
|
private LocalMetadataRepository createRepository(File location) throws ProvisionException {
|
|
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
|
|
index 36946bf..ae435c2 100644
|
|
--- 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
|
|
@@ -23,6 +23,7 @@ import java.util.Set;
|
|
import org.eclipse.equinox.p2.core.IProvisioningAgent;
|
|
import org.eclipse.equinox.p2.metadata.IArtifactKey;
|
|
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
import org.eclipse.tycho.p2.maven.repository.Activator;
|
|
import org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO;
|
|
import org.eclipse.tycho.p2.repository.GAV;
|
|
@@ -42,15 +43,16 @@ public class LocalArtifactRepository extends ArtifactRepositoryBaseImpl<GAVArtif
|
|
|
|
// TODO what is the agent needed for? does using the default agent harm?
|
|
public LocalArtifactRepository(LocalRepositoryP2Indices localRepoIndices) {
|
|
- this(Activator.getProvisioningAgent(), localRepoIndices);
|
|
+ this(Activator.getProvisioningAgent(), localRepoIndices, (MavenRepositorySystem) null);
|
|
}
|
|
|
|
public LocalArtifactRepository(LocalRepositoryP2Indices localRepoIndices, RepositoryReader contentLocator) {
|
|
this(Activator.getProvisioningAgent(), localRepoIndices, contentLocator);
|
|
}
|
|
|
|
- public LocalArtifactRepository(IProvisioningAgent agent, LocalRepositoryP2Indices localRepoIndices) {
|
|
- this(agent, localRepoIndices, new LocalRepositoryReader(localRepoIndices.getBasedir()));
|
|
+ public LocalArtifactRepository(IProvisioningAgent agent, LocalRepositoryP2Indices localRepoIndices,
|
|
+ MavenRepositorySystem repositorySystem) {
|
|
+ this(agent, localRepoIndices, new LocalRepositoryReader(localRepoIndices.getBasedir(), repositorySystem));
|
|
}
|
|
|
|
public LocalArtifactRepository(IProvisioningAgent agent, LocalRepositoryP2Indices localRepoIndices,
|
|
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
|
|
index fc99483..187d84f 100644
|
|
--- 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
|
|
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
|
import org.eclipse.equinox.p2.core.ProvisionException;
|
|
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository;
|
|
import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactRepositoryFactory;
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
import org.eclipse.tycho.p2.maven.repository.Activator;
|
|
import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices;
|
|
import org.eclipse.tycho.repository.util.internal.RepositoryFactoryTools;
|
|
@@ -41,7 +42,7 @@ public class LocalArtifactRepositoryFactory extends ArtifactRepositoryFactory {
|
|
if (localRepositoryDirectory.isDirectory()
|
|
&& new File(localRepositoryDirectory, ".meta/p2-artifacts.properties").exists()) {
|
|
// see FileBasedTychoRepositoryIndex#ARTIFACTS_INDEX_RELPATH
|
|
- return new LocalArtifactRepository(getAgent(), lookupLocalRepoIndices());
|
|
+ return new LocalArtifactRepository(getAgent(), lookupLocalRepoIndices(), lookupLocalRepoIndices().getRepositorySystem());
|
|
}
|
|
}
|
|
return null;
|
|
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
|
|
index e727bdb..6f4f860 100644
|
|
--- 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
|
|
@@ -14,6 +14,7 @@ package org.eclipse.tycho.repository.local.index;
|
|
import java.io.File;
|
|
|
|
import org.eclipse.tycho.core.facade.MavenContext;
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
import org.eclipse.tycho.locking.facade.FileLockService;
|
|
import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices;
|
|
import org.eclipse.tycho.p2.repository.TychoRepositoryIndex;
|
|
@@ -23,6 +24,7 @@ public class LocalRepositoryP2IndicesImpl implements LocalRepositoryP2Indices {
|
|
// injected members
|
|
private FileLockService fileLockService;
|
|
private File localRepositoryRoot;
|
|
+ private MavenRepositorySystem repoSystem;
|
|
|
|
// derived members
|
|
private boolean initialized = false;
|
|
@@ -36,6 +38,7 @@ public class LocalRepositoryP2IndicesImpl implements LocalRepositoryP2Indices {
|
|
// injected by DS runtime
|
|
public void setMavenContext(MavenContext mavenContext) {
|
|
this.localRepositoryRoot = mavenContext.getLocalRepositoryRoot();
|
|
+ this.repoSystem = mavenContext.getRepositorySystem();
|
|
}
|
|
|
|
// injected by DS runtime
|
|
@@ -72,4 +75,8 @@ public class LocalRepositoryP2IndicesImpl implements LocalRepositoryP2Indices {
|
|
return localRepositoryRoot;
|
|
}
|
|
|
|
+ public MavenRepositorySystem getRepositorySystem() {
|
|
+ return repoSystem;
|
|
+ }
|
|
+
|
|
}
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/META-INF/MANIFEST.MF b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/META-INF/MANIFEST.MF
|
|
index 85de919..7d95087 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/META-INF/MANIFEST.MF
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl.test/META-INF/MANIFEST.MF
|
|
@@ -11,6 +11,7 @@ Require-Bundle: org.junit,
|
|
Bundle-ActivationPolicy: lazy
|
|
Bundle-Vendor: %providerName
|
|
Import-Package: org.eclipse.tycho.p2.testutil,
|
|
+ org.eclipse.tycho.repository.local.testutil,
|
|
org.eclipse.tycho.repository.streaming.testutil,
|
|
org.eclipse.tycho.repository.testutil,
|
|
org.eclipse.tycho.test.util
|
|
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
|
|
index fea1158..e131811 100644
|
|
--- 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
|
|
@@ -35,6 +35,7 @@ import org.eclipse.tycho.core.facade.MavenContextImpl;
|
|
import org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation;
|
|
import org.eclipse.tycho.core.resolver.shared.MavenRepositorySettings;
|
|
import org.eclipse.tycho.p2.impl.test.ResourceUtil;
|
|
+import org.eclipse.tycho.repository.local.testutil.MavenRepositorySystemStub;
|
|
import org.eclipse.tycho.test.util.HttpServer;
|
|
import org.eclipse.tycho.test.util.LogVerifier;
|
|
import org.junit.After;
|
|
@@ -61,7 +62,7 @@ public class RemoteAgentMavenMirrorsTest {
|
|
public void initSubject() throws Exception {
|
|
File localRepository = tempManager.newFolder("localRepo");
|
|
MavenContext mavenContext = new MavenContextImpl(localRepository, OFFLINE, logVerifier.getLogger(),
|
|
- new Properties());
|
|
+ new Properties(), new MavenRepositorySystemStub(localRepository));
|
|
|
|
mavenRepositorySettings = new MavenRepositorySettingsStub();
|
|
subject = new RemoteAgent(mavenContext, mavenRepositorySettings, OFFLINE);
|
|
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
|
|
index 9fbecb6..1c4f9b9 100644
|
|
--- 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
|
|
@@ -24,6 +24,7 @@ import org.eclipse.equinox.p2.core.ProvisionException;
|
|
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
|
|
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager;
|
|
import org.eclipse.tycho.core.facade.MavenContextImpl;
|
|
+import org.eclipse.tycho.repository.local.testutil.MavenRepositorySystemStub;
|
|
import org.eclipse.tycho.test.util.HttpServer;
|
|
import org.eclipse.tycho.test.util.LogVerifier;
|
|
import org.junit.Before;
|
|
@@ -126,12 +127,12 @@ public class RemoteAgentMetadataRepositoryCacheTest {
|
|
|
|
private RemoteAgent newOnlineAgent() throws Exception {
|
|
return new RemoteAgent(new MavenContextImpl(localMavenRepository, false, logVerifier.getLogger(),
|
|
- new Properties()));
|
|
+ new Properties(), new MavenRepositorySystemStub(localMavenRepository)));
|
|
}
|
|
|
|
private RemoteAgent newOfflineAgent() throws Exception {
|
|
return new RemoteAgent(new MavenContextImpl(localMavenRepository, true, logVerifier.getLogger(),
|
|
- new Properties()));
|
|
+ new Properties(), new MavenRepositorySystemStub(localMavenRepository)));
|
|
}
|
|
|
|
private IMetadataRepository loadHttpRepository(RemoteAgent agent) throws ProvisionException {
|
|
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
|
|
index 50fe92f..0747f07 100644
|
|
--- 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
|
|
@@ -28,6 +28,7 @@ import org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor;
|
|
import org.eclipse.tycho.p2.impl.test.ArtifactMock;
|
|
import org.eclipse.tycho.p2.metadata.IArtifactFacade;
|
|
import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
|
|
+import org.eclipse.tycho.repository.local.testutil.MavenRepositorySystemStub;
|
|
import org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactProvider;
|
|
import org.eclipse.tycho.repository.streaming.testutil.ProbeRawArtifactSink;
|
|
import org.eclipse.tycho.test.util.LogVerifier;
|
|
@@ -56,7 +57,7 @@ public class TargetPlatformBundlePublisherTest {
|
|
logVerifier.expectNoWarnings();
|
|
|
|
localRepositoryRoot = tempFolder.getRoot();
|
|
- subject = new TargetPlatformBundlePublisher(localRepositoryRoot, logVerifier.getLogger());
|
|
+ subject = new TargetPlatformBundlePublisher(localRepositoryRoot, logVerifier.getLogger(), new MavenRepositorySystemStub(localRepositoryRoot));
|
|
}
|
|
|
|
@Test
|
|
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
|
|
index eba1e68..abf93e4 100644
|
|
--- 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
|
|
@@ -28,6 +28,7 @@ import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory;
|
|
import org.eclipse.tycho.repository.local.LocalArtifactRepository;
|
|
import org.eclipse.tycho.repository.local.LocalMetadataRepository;
|
|
import org.eclipse.tycho.repository.local.index.LocalRepositoryP2IndicesImpl;
|
|
+import org.eclipse.tycho.repository.local.testutil.MavenRepositorySystemStub;
|
|
import org.eclipse.tycho.test.util.NoopFileLockService;
|
|
|
|
public class TestResolverFactory implements P2ResolverFactory {
|
|
@@ -45,7 +46,7 @@ public class TestResolverFactory implements P2ResolverFactory {
|
|
|
|
File localMavenRepoRoot = mavenContext.getLocalRepositoryRoot();
|
|
LocalRepositoryP2Indices localRepoIndices = createLocalRepoIndices(mavenContext);
|
|
- LocalRepositoryReader localRepositoryReader = new LocalRepositoryReader(localMavenRepoRoot);
|
|
+ LocalRepositoryReader localRepositoryReader = new LocalRepositoryReader(localMavenRepoRoot, mavenContext.getRepositorySystem());
|
|
localMetadataRepo = new LocalMetadataRepository(localMavenRepoRoot.toURI(),
|
|
localRepoIndices.getMetadataIndex(), localRepositoryReader);
|
|
localArtifactRepo = new LocalArtifactRepository(localRepoIndices, localRepositoryReader);
|
|
@@ -56,7 +57,7 @@ public class TestResolverFactory implements P2ResolverFactory {
|
|
}
|
|
|
|
private MavenContext createMavenContext(boolean offline, MavenLogger logger) {
|
|
- return new MavenContextImpl(getLocalRepositoryLocation(), offline, logger, new Properties());
|
|
+ return new MavenContextImpl(getLocalRepositoryLocation(), offline, logger, new Properties(), new MavenRepositorySystemStub(getLocalRepositoryLocation()));
|
|
}
|
|
|
|
// TODO use TemporaryLocalMavenRepository
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
|
|
index 2b7c306..a0270e2 100644
|
|
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
|
|
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
|
|
@@ -33,7 +33,7 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory {
|
|
private static LocalMetadataRepository localMetadataRepository;
|
|
private static LocalArtifactRepository localArtifactRepository;
|
|
|
|
- private MavenContext mavenContext;
|
|
+ private static MavenContext mavenContext;
|
|
private LocalRepositoryP2Indices localRepoIndices;
|
|
private RemoteAgentManager remoteAgentManager;
|
|
private TargetDefinitionResolverService targetDefinitionResolverService;
|
|
@@ -42,7 +42,8 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory {
|
|
LocalRepositoryP2Indices localRepoIndices) {
|
|
if (localMetadataRepository == null) {
|
|
File localMavenRepoRoot = context.getLocalRepositoryRoot();
|
|
- RepositoryReader contentLocator = new LocalRepositoryReader(localMavenRepoRoot);
|
|
+ RepositoryReader contentLocator = new LocalRepositoryReader(localMavenRepoRoot,
|
|
+ mavenContext.getRepositorySystem());
|
|
localMetadataRepository = new LocalMetadataRepository(localMavenRepoRoot.toURI(),
|
|
localRepoIndices.getMetadataIndex(), contentLocator);
|
|
|
|
@@ -53,7 +54,8 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory {
|
|
private static synchronized LocalArtifactRepository getLocalArtifactRepository(MavenContext mavenContext,
|
|
LocalRepositoryP2Indices localRepoIndices) {
|
|
if (localArtifactRepository == null) {
|
|
- RepositoryReader contentLocator = new LocalRepositoryReader(mavenContext.getLocalRepositoryRoot());
|
|
+ RepositoryReader contentLocator = new LocalRepositoryReader(mavenContext.getLocalRepositoryRoot(),
|
|
+ mavenContext.getRepositorySystem());
|
|
localArtifactRepository = new LocalArtifactRepository(localRepoIndices, contentLocator);
|
|
}
|
|
return localArtifactRepository;
|
|
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
|
|
index 0fa7b09..7044c2f 100644
|
|
--- 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
|
|
@@ -45,7 +45,7 @@ public class PomDependencyCollectorImpl implements PomDependencyCollector {
|
|
this.logger = mavenContext.getLogger();
|
|
|
|
File localRepositoryRoot = mavenContext.getLocalRepositoryRoot();
|
|
- this.bundlesPublisher = new TargetPlatformBundlePublisher(localRepositoryRoot, mavenContext.getLogger());
|
|
+ this.bundlesPublisher = new TargetPlatformBundlePublisher(localRepositoryRoot, mavenContext.getLogger(), mavenContext.getRepositorySystem());
|
|
}
|
|
|
|
public void setProjectLocation(File projectLocation) {
|
|
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 8281167..5766806 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
|
|
@@ -25,6 +25,7 @@ import org.eclipse.equinox.p2.publisher.PublisherResult;
|
|
import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction;
|
|
import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor;
|
|
import org.eclipse.tycho.core.facade.MavenLogger;
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
import org.eclipse.tycho.p2.impl.publisher.MavenPropertiesAdvice;
|
|
import org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository;
|
|
import org.eclipse.tycho.p2.metadata.IArtifactFacade;
|
|
@@ -42,8 +43,8 @@ public class TargetPlatformBundlePublisher {
|
|
private final MavenLogger logger;
|
|
private final PublishedBundlesArtifactRepository publishedArtifacts;
|
|
|
|
- public TargetPlatformBundlePublisher(File localMavenRepositoryRoot, MavenLogger logger) {
|
|
- this.publishedArtifacts = new PublishedBundlesArtifactRepository(localMavenRepositoryRoot);
|
|
+ public TargetPlatformBundlePublisher(File localMavenRepositoryRoot, MavenLogger logger, MavenRepositorySystem repositorySystem) {
|
|
+ this.publishedArtifacts = new PublishedBundlesArtifactRepository(localMavenRepositoryRoot, repositorySystem);
|
|
this.logger = logger;
|
|
}
|
|
|
|
@@ -206,8 +207,11 @@ public class TargetPlatformBundlePublisher {
|
|
*/
|
|
private static class PublishedBundlesArtifactRepository extends ArtifactRepositoryBaseImpl<GAVArtifactDescriptor> {
|
|
|
|
- PublishedBundlesArtifactRepository(File localMavenRepositoryRoot) {
|
|
+ private MavenRepositorySystem repositorySystem;
|
|
+
|
|
+ PublishedBundlesArtifactRepository(File localMavenRepositoryRoot, MavenRepositorySystem repositorySystem) {
|
|
super(null, localMavenRepositoryRoot.toURI(), ArtifactTransferPolicies.forLocalArtifacts());
|
|
+ this.repositorySystem = repositorySystem;
|
|
}
|
|
|
|
void addPublishedArtifact(IArtifactDescriptor baseDescriptor, IArtifactFacade mavenArtifact) {
|
|
@@ -252,8 +256,9 @@ public class TargetPlatformBundlePublisher {
|
|
@Override
|
|
protected File internalGetArtifactStorageLocation(IArtifactDescriptor descriptor) {
|
|
MavenRepositoryCoordinates coord = toInternalDescriptor(descriptor).getMavenCoordinates();
|
|
- LocalRepositoryReader reader = new LocalRepositoryReader(getBaseDir());
|
|
- return reader.getLocalArtifactLocation(coord.getGav(), coord.getClassifier(), coord.getExtensionOrDefault());
|
|
+ LocalRepositoryReader reader = new LocalRepositoryReader(getBaseDir(), repositorySystem);
|
|
+ return reader
|
|
+ .getLocalArtifactLocation(coord.getGav(), coord.getClassifier(), coord.getExtensionOrDefault());
|
|
}
|
|
|
|
private File getBaseDir() {
|
|
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
|
|
index 2122578..54c46fc 100644
|
|
--- 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
|
|
@@ -13,6 +13,8 @@ package org.eclipse.tycho.p2.repository;
|
|
|
|
import java.io.File;
|
|
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
+
|
|
/**
|
|
* This service provides access to the tycho p2 index files of the local maven repository.
|
|
*/
|
|
@@ -24,4 +26,6 @@ public interface LocalRepositoryP2Indices {
|
|
|
|
public File getBasedir();
|
|
|
|
+ public MavenRepositorySystem getRepositorySystem();
|
|
+
|
|
}
|
|
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 b5c8c55..8091db6 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,57 +11,19 @@
|
|
package org.eclipse.tycho.p2.repository;
|
|
|
|
import java.io.File;
|
|
-import java.lang.reflect.Constructor;
|
|
-import java.lang.reflect.Method;
|
|
+
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
|
|
public class LocalRepositoryReader implements RepositoryReader {
|
|
|
|
- private final File localMavenRepositoryRoot;
|
|
+ private final MavenRepositorySystem repositorySystem;
|
|
|
|
- public LocalRepositoryReader(File localMavenRepositoryRoot) {
|
|
- this.localMavenRepositoryRoot = localMavenRepositoryRoot;
|
|
+ public LocalRepositoryReader(File localMavenRepositoryRoot, MavenRepositorySystem repositorySystem) {
|
|
+ this.repositorySystem = repositorySystem;
|
|
}
|
|
|
|
- @SuppressWarnings({ "unchecked", "rawtypes" })
|
|
public File getLocalArtifactLocation(GAV gav, String classifier, String 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;
|
|
-
|
|
+ return repositorySystem != null ? repositorySystem.resolve(gav.getGroupId(), gav.getArtifactId(),
|
|
+ gav.getVersion(), extension, classifier) : null;
|
|
}
|
|
}
|
|
diff --git a/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/MavenRepositorySystemStub.java b/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/MavenRepositorySystemStub.java
|
|
new file mode 100644
|
|
index 0000000..a59d7e6
|
|
--- /dev/null
|
|
+++ b/tycho-bundles/org.eclipse.tycho.test.utils/src/main/java/org/eclipse/tycho/repository/local/testutil/MavenRepositorySystemStub.java
|
|
@@ -0,0 +1,30 @@
|
|
+/*******************************************************************************
|
|
+ * Copyright (c) 2014 Red Hat Inc.
|
|
+ * All rights reserved. This program and the accompanying materials
|
|
+ * are made available under the terms of the Eclipse Public License v1.0
|
|
+ * which accompanies this distribution, and is available at
|
|
+ * http://www.eclipse.org/legal/epl-v10.html
|
|
+ *
|
|
+ * Contributors:
|
|
+ * Red Hat Inc. - initial API and implementation
|
|
+ *******************************************************************************/
|
|
+package org.eclipse.tycho.repository.local.testutil;
|
|
+
|
|
+import java.io.File;
|
|
+
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
+import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
|
|
+
|
|
+public class MavenRepositorySystemStub implements MavenRepositorySystem {
|
|
+
|
|
+ private File localMavenRepositoryRoot;
|
|
+
|
|
+ public MavenRepositorySystemStub(File localMavenRepositoryRoot) {
|
|
+ this.localMavenRepositoryRoot = localMavenRepositoryRoot;
|
|
+ }
|
|
+
|
|
+ public File resolve(String gid, String aid, String version, String type, String classifier) {
|
|
+ return new File(localMavenRepositoryRoot, RepositoryLayoutHelper.getRelativePath(gid, aid, version, classifier,
|
|
+ type));
|
|
+ }
|
|
+}
|
|
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
|
|
index f7cc92c..0e6465f 100644
|
|
--- 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
|
|
@@ -14,6 +14,7 @@ import java.io.File;
|
|
import java.io.IOException;
|
|
|
|
import org.eclipse.equinox.internal.p2.core.helpers.FileUtils;
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices;
|
|
import org.eclipse.tycho.repository.local.LocalArtifactRepository;
|
|
import org.eclipse.tycho.repository.local.index.LocalRepositoryP2IndicesImpl;
|
|
@@ -72,7 +73,7 @@ public class TemporaryLocalMavenRepository extends ExternalResource {
|
|
|
|
public LocalArtifactRepository getLocalArtifactRepository() {
|
|
if (repo == null) {
|
|
- repo = new LocalArtifactRepository(null, getLocalRepositoryIndex());
|
|
+ repo = new LocalArtifactRepository(null, getLocalRepositoryIndex(), new MavenRepositorySystemStub(getLocalRepositoryRoot()));
|
|
}
|
|
return repo;
|
|
}
|
|
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
|
|
new file mode 100644
|
|
index 0000000..7c22f62
|
|
--- /dev/null
|
|
+++ b/tycho-core/src/main/java/org/eclipse/tycho/osgi/adapters/MavenRepositorySystemAdapter.java
|
|
@@ -0,0 +1,37 @@
|
|
+/*******************************************************************************
|
|
+ * Copyright (c) 2014 Red Hat Inc.
|
|
+ * All rights reserved. This program and the accompanying materials
|
|
+ * are made available under the terms of the Eclipse Public License v1.0
|
|
+ * which accompanies this distribution, and is available at
|
|
+ * http://www.eclipse.org/legal/epl-v10.html
|
|
+ *
|
|
+ * Contributors:
|
|
+ * Red Hat Inc. - initial API and implementation
|
|
+ *******************************************************************************/
|
|
+package org.eclipse.tycho.osgi.adapters;
|
|
+
|
|
+import java.io.File;
|
|
+
|
|
+import org.apache.maven.artifact.Artifact;
|
|
+import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
|
+import org.apache.maven.artifact.resolver.ArtifactResolutionResult;
|
|
+import org.apache.maven.repository.RepositorySystem;
|
|
+import org.eclipse.tycho.core.facade.MavenRepositorySystem;
|
|
+
|
|
+public class MavenRepositorySystemAdapter implements MavenRepositorySystem {
|
|
+
|
|
+ private RepositorySystem repoSystem;
|
|
+
|
|
+ public MavenRepositorySystemAdapter(RepositorySystem repoSystem) {
|
|
+ this.repoSystem = repoSystem;
|
|
+ }
|
|
+
|
|
+ public File resolve(String gid, String aid, String version, String type, String classifier) {
|
|
+ ArtifactResolutionRequest req = new ArtifactResolutionRequest();
|
|
+ Artifact art = repoSystem.createArtifactWithClassifier(gid, aid, version, type, classifier);
|
|
+ req.setArtifact(art);
|
|
+ ArtifactResolutionResult res = repoSystem.resolve(req);
|
|
+ return res.getArtifacts().size() > 0 ? res.getArtifacts().toArray(new Artifact[0])[0].getFile() : null;
|
|
+ }
|
|
+
|
|
+}
|
|
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
|
|
index cde12ad..dd907a2 100644
|
|
--- 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
|
|
@@ -16,6 +16,7 @@ import java.util.Properties;
|
|
|
|
import org.apache.maven.execution.MavenSession;
|
|
import org.apache.maven.plugin.LegacySupport;
|
|
+import org.apache.maven.repository.RepositorySystem;
|
|
import org.apache.maven.settings.Profile;
|
|
import org.apache.maven.settings.Settings;
|
|
import org.codehaus.plexus.component.annotations.Component;
|
|
@@ -26,6 +27,7 @@ import org.eclipse.sisu.equinox.embedder.EquinoxLifecycleListener;
|
|
import org.eclipse.tycho.core.facade.MavenContext;
|
|
import org.eclipse.tycho.core.facade.MavenContextImpl;
|
|
import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter;
|
|
+import org.eclipse.tycho.osgi.adapters.MavenRepositorySystemAdapter;
|
|
|
|
@Component(role = EquinoxLifecycleListener.class, hint = "MavenContextConfigurator")
|
|
public class MavenContextConfigurator extends EquinoxLifecycleListener {
|
|
@@ -36,13 +38,17 @@ public class MavenContextConfigurator extends EquinoxLifecycleListener {
|
|
@Requirement
|
|
private LegacySupport context;
|
|
|
|
+ @Requirement
|
|
+ private RepositorySystem repositorySystem;
|
|
+
|
|
@Override
|
|
public void afterFrameworkStarted(EmbeddedEquinox framework) {
|
|
MavenSession session = context.getSession();
|
|
File localRepoRoot = new File(session.getLocalRepository().getBasedir());
|
|
MavenLoggerAdapter mavenLogger = new MavenLoggerAdapter(logger, false);
|
|
Properties globalProps = getGlobalProperties(session);
|
|
- MavenContext mavenContext = new MavenContextImpl(localRepoRoot, session.isOffline(), mavenLogger, globalProps);
|
|
+ MavenContext mavenContext = new MavenContextImpl(localRepoRoot, session.isOffline(), mavenLogger, globalProps,
|
|
+ new MavenRepositorySystemAdapter(repositorySystem));
|
|
framework.registerService(MavenContext.class, mavenContext);
|
|
}
|
|
|
|
--
|
|
1.9.3
|
|
|