Search in sources :

Example 1 with LocalDependencyResolver

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;
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) MavenSession(org.apache.maven.execution.MavenSession) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository) File(java.io.File)

Example 2 with LocalDependencyResolver

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;
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) MavenSession(org.apache.maven.execution.MavenSession) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository)

Example 3 with LocalDependencyResolver

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;
}
Also used : LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) Properties(java.util.Properties) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) File(java.io.File) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver)

Aggregations

DependencyResolver (org.eclipse.tycho.core.DependencyResolver)3 LocalDependencyResolver (org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver)3 File (java.io.File)2 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)2 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)2 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)2 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)2 MavenSession (org.apache.maven.execution.MavenSession)2 LegacySupport (org.apache.maven.plugin.LegacySupport)2 StubArtifactRepository (org.apache.maven.plugin.testing.stubs.StubArtifactRepository)2 MavenProject (org.apache.maven.project.MavenProject)2 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)2 DefaultRepositorySystemSession (org.sonatype.aether.util.DefaultRepositorySystemSession)2 IOException (java.io.IOException)1 Properties (java.util.Properties)1 ComponentLookupException (org.codehaus.plexus.component.repository.exception.ComponentLookupException)1 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)1