use of org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver in project tycho by eclipse.
the class ArtifactDependencyWalkerTest method getTargetPlatform.
protected DependencyArtifacts getTargetPlatform() throws Exception {
LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setLocalRepository(new StubArtifactRepository(System.getProperty("java.io.tmpdir")));
MavenExecutionResult result = new DefaultMavenExecutionResult();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
session.setProjects(new ArrayList<MavenProject>());
lookup(LegacySupport.class).setSession(session);
MavenProject project = new MavenProject();
resolver.setLocation(new File("src/test/resources/targetplatforms/basic"));
DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
return platform;
}
use of org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver in project tycho by eclipse.
the class LocalDependencyResolverTest method getTargetPlatform.
protected DependencyArtifacts getTargetPlatform(File location) throws Exception, IOException {
LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setLocalRepository(new StubArtifactRepository(location.getAbsolutePath()));
MavenExecutionResult result = new DefaultMavenExecutionResult();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
session.setProjects(new ArrayList<MavenProject>());
lookup(LegacySupport.class).setSession(session);
MavenProject project = new MavenProject();
resolver.setLocation(location);
DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
return platform;
}
use of org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver in project tycho by eclipse.
the class DefaultDependencyResolverFactory method lookupDependencyResolver.
public DependencyResolver lookupDependencyResolver(MavenProject project) {
Properties properties = (Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES);
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
String property = properties.getProperty("tycho.targetPlatform");
DependencyResolver resolver;
if (property != null) {
logger.warn("-Dtycho.targetPlatform is deprecated and WILL be removed in the next Tycho version.");
File location = new File(property);
if (!location.exists() || !location.isDirectory()) {
throw new RuntimeException("Invalid target platform location: " + property);
}
try {
resolver = container.lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
} catch (ComponentLookupException e) {
throw new RuntimeException("Could not instantiate required component", e);
}
try {
((LocalDependencyResolver) resolver).setLocation(new File(property));
} catch (IOException e) {
throw new RuntimeException("Could not create target platform", e);
}
return resolver;
}
String resolverRole = configuration.getTargetPlatformResolver();
if (resolverRole == null) {
resolverRole = DEFAULT_RESOLVER_HINT;
}
try {
resolver = container.lookup(DependencyResolver.class, resolverRole);
} catch (ComponentLookupException e) {
throw new RuntimeException("Could not instantiate required component", e);
}
return resolver;
}
Aggregations