Search in sources :

Example 1 with DependencyArtifacts

use of org.eclipse.tycho.artifacts.DependencyArtifacts 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 DependencyArtifacts

use of org.eclipse.tycho.artifacts.DependencyArtifacts in project tycho by eclipse.

the class DependencyComputerTest method computeDependencies.

private List<DependencyEntry> computeDependencies(MavenProject project) throws BundleException {
    DependencyArtifacts platform = (DependencyArtifacts) project.getContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS);
    State state = resolver.newResolvedState(project, ExecutionEnvironmentUtils.getExecutionEnvironment("J2SE-1.4"), false, platform);
    BundleDescription bundle = state.getBundleByLocation(project.getBasedir().getAbsolutePath());
    return dependencyComputer.computeDependencies(state.getStateHelper(), bundle);
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription)

Example 3 with DependencyArtifacts

use of org.eclipse.tycho.artifacts.DependencyArtifacts in project tycho by eclipse.

the class DependencyComputerTest method testExportPackage.

@Test
public void testExportPackage() throws Exception {
    File basedir = getBasedir("projects/exportpackage");
    Map<File, MavenProject> basedirMap = MavenSessionUtils.getBasedirMap(getSortedProjects(basedir, null));
    MavenProject project = basedirMap.get(new File(basedir, "bundle"));
    DependencyArtifacts platform = (DependencyArtifacts) project.getContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS);
    ExecutionEnvironment executionEnvironment = TychoProjectUtils.getExecutionEnvironmentConfiguration(project).getFullSpecification();
    State state = resolver.newResolvedState(project, executionEnvironment, false, platform);
    BundleDescription bundle = state.getBundleByLocation(project.getBasedir().getAbsolutePath());
    List<DependencyEntry> dependencies = dependencyComputer.computeDependencies(state.getStateHelper(), bundle);
    Assert.assertEquals(3, dependencies.size());
    Assert.assertEquals("dep", dependencies.get(0).desc.getSymbolicName());
    Assert.assertEquals("dep2", dependencies.get(1).desc.getSymbolicName());
    Assert.assertEquals("dep3", dependencies.get(2).desc.getSymbolicName());
    Assert.assertTrue(dependencies.get(2).rules.isEmpty());
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) CustomExecutionEnvironment(org.eclipse.tycho.core.ee.CustomExecutionEnvironment) ExecutionEnvironment(org.eclipse.tycho.core.ee.shared.ExecutionEnvironment) MavenProject(org.apache.maven.project.MavenProject) State(org.eclipse.osgi.service.resolver.State) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) DependencyEntry(org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry) File(java.io.File) Test(org.junit.Test)

Example 4 with DependencyArtifacts

use of org.eclipse.tycho.artifacts.DependencyArtifacts in project tycho by eclipse.

the class LocalDependencyResolverTest method testBundleIdParsing.

public void testBundleIdParsing() throws Exception {
    DependencyArtifacts platform = getTargetPlatform(new File("src/test/resources/targetplatforms/basic"));
    ArtifactDescriptor artifact = platform.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "bundle01", null);
    ArtifactKey key = artifact.getKey();
    assertEquals("bundle01", key.getId());
    assertEquals("0.0.1", key.getVersion());
    File file = artifact.getLocation();
    assertEquals("bundle01_0.0.1", file.getName());
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) File(java.io.File)

Example 5 with DependencyArtifacts

use of org.eclipse.tycho.artifacts.DependencyArtifacts in project tycho by eclipse.

the class LocalDependencyResolverTest method testBundleRelativePath.

public void testBundleRelativePath() throws Exception {
    File platformPath = new File("src/test/resources/targetplatforms/basic").getAbsoluteFile();
    DependencyArtifacts platform = getTargetPlatform(platformPath);
    File bundlePath = new File("src/test/resources/targetplatforms/basic/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar");
    Map<String, ArtifactDescriptor> artifact = platform.getArtifact(bundlePath);
    assertNotNull(artifact);
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) File(java.io.File)

Aggregations

DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)16 File (java.io.File)13 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)8 MavenProject (org.apache.maven.project.MavenProject)5 DependencyResolver (org.eclipse.tycho.core.DependencyResolver)5 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)4 State (org.eclipse.osgi.service.resolver.State)4 ReactorProject (org.eclipse.tycho.ReactorProject)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ArtifactKey (org.eclipse.tycho.ArtifactKey)3 DependencyResolverConfiguration (org.eclipse.tycho.core.DependencyResolverConfiguration)3 DependencyEntry (org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry)3 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 Dependency (org.apache.maven.model.Dependency)2 LegacySupport (org.apache.maven.plugin.LegacySupport)2 StubArtifactRepository (org.apache.maven.plugin.testing.stubs.StubArtifactRepository)2