Do not use XMvn internals (Bug 1015038).

This commit is contained in:
Roland Grunberg 2013-10-04 10:34:37 -04:00
parent bb87890557
commit d3195d8608
2 changed files with 25 additions and 24 deletions

View File

@ -1,4 +1,4 @@
From 92cdfc9a21142cc866265b45b37e85547145d15d Mon Sep 17 00:00:00 2001
From b9f8979d98b98536679ec562e272911da287a476 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.
@ -151,18 +151,19 @@ index 5b61351..b81f6be 100644
if (includeLocalMavenRepo && logger.isDebugEnabled()) {
IQueryResult<IInstallableUnit> locallyInstalledIUs = localMetadataRepository.query(QueryUtil.ALL_UNITS,
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/repository/LocalRepositoryReader.java
index 8d36462..eb05eff 100644
index 8d36462..4c8c582 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,7 @@
@@ -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 {
@@ -21,7 +22,33 @@ public class LocalRepositoryReader implements RepositoryReader {
@@ -21,7 +23,32 @@ public class LocalRepositoryReader implements RepositoryReader {
}
public File getLocalArtifactLocation(GAV gav, String classifier, String extension) {
@ -172,24 +173,23 @@ index 8d36462..eb05eff 100644
+ // In Fedora the artifact may be in an XMvn-defined repository location (not in reactor cache)
+ if (!file.exists()) {
+ try {
+ // Use plexus container to add, and lookup the resolver
+ // Use plexus container to lookup the reader
+ Class pclazz = Class.forName("org.codehaus.plexus.DefaultPlexusContainer");
+ Object plexus = pclazz.newInstance();
+
+ // The resolver
+ Class rclazz = Class.forName("org.fedoraproject.maven.resolver.impl.DefaultResolver");
+
+ // Add the resolver to the plexus container
+ Method mAdd = pclazz.getMethod("addComponent", Object.class, String.class);
+ mAdd.invoke(plexus, rclazz.newInstance(), "org.fedoraproject.maven.resolver.Resolver");
+ // Retrieve the resolver from the plexus container
+ // Retrieve the workspace reader from the plexus container
+ Method mLookup = pclazz.getMethod("lookup", String.class);
+ Object reader = mLookup.invoke(plexus, "org.fedoraproject.maven.resolver.Resolver");
+ Object reader = mLookup.invoke(plexus, "org.eclipse.aether.repository.WorkspaceReader");
+
+ // Invoke "resolve" method of the resolver
+ Method mResolve = reader.getClass().getMethod("resolve", String.class, String.class, String.class, String.class);
+ file = (File) mResolve.invoke(reader, gav.getGroupId(), gav.getArtifactId(), gav.getVersion(), extension);
+ // 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 = (File) mfindArtifact.invoke(reader, artifact);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
@ -199,7 +199,7 @@ index 8d36462..eb05eff 100644
+ }
}
diff --git a/tycho-core/pom.xml b/tycho-core/pom.xml
index d1289b6..53cdc7a 100644
index d1289b6..45f7ee9 100644
--- a/tycho-core/pom.xml
+++ b/tycho-core/pom.xml
@@ -146,6 +146,11 @@
@ -208,8 +208,8 @@ index d1289b6..53cdc7a 100644
</dependency>
+ <dependency>
+ <groupId>org.fedoraproject.xmvn</groupId>
+ <artifactId>xmvn-core</artifactId>
+ <version>0.3.0</version>
+ <artifactId>xmvn-connector</artifactId>
+ <version>1.1.0</version>
+ </dependency>
<dependency>
@ -495,5 +495,5 @@ index f6f56ac..b9b8cba 100644
addOtherReactorProjectsToTargetPlatform(project, reactorProjects, tpBuilder);
--
1.8.1.4
1.8.3.1

View File

@ -9,7 +9,7 @@
Name: tycho
Version: 0.18.1
Release: 6%{?dist}
Release: 7%{?dist}
Summary: Plugins and extensions for building Eclipse plugins and OSGI bundles with Maven
Group: Development/Libraries
@ -50,8 +50,6 @@ BuildRequires: maven-local
BuildRequires: maven-clean-plugin
BuildRequires: maven-compiler-plugin
BuildRequires: maven-dependency-plugin
# Temporarily added to avoid bootstrap build
BuildRequires: maven-deploy-plugin
BuildRequires: maven-install-plugin
BuildRequires: maven-jar-plugin
BuildRequires: maven-javadoc-plugin
@ -309,6 +307,9 @@ sed -i 's|<maven>|&<extension>zip</extension>|' \
%{_javadocdir}/%{name}
%changelog
* Fri Oct 04 2013 Roland Grunberg <rgrunber@redhat.com> - 0.18.1-7
- Do not use XMvn internals (Bug 1015038).
* Thu Oct 3 2013 Krzysztof Daniel <kdaniel@redhat.com> 0.18.1-6
- Adjust to latest Xmvn (workaround for 1015038).