Search in sources :

Example 1 with Repository

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.

the class TargetDefinitionResolverExecutionEnvironmentTest method testAutoGeneratedExecutionEnvironment.

@Test
public void testAutoGeneratedExecutionEnvironment() throws Exception {
    subject = targetResolverForEE("JavaSE-1.7");
    TargetDefinition definition = definitionWith(new AlternatePackageProviderLocationStub());
    Collection<IInstallableUnit> units = subject.resolveContent(definition).getUnits();
    // expect that resolver did not included a bundle providing org.w3c.dom...
    assertThat(units, not(hasItem(unit("javax.xml", "0.0.1.SNAPSHOT"))));
    // ... but instead included the configured 'a.jre' IU (which is not contained in the repository)
    assertThat(units, hasItem(unit("a.jre.javase", "1.7.0")));
    // other "a.jre" IUs from the repository shall be filtered out
    assertThat(units, not(hasItem(unitWithId("a.jre"))));
}
Also used : TargetDefinition(org.eclipse.tycho.p2.target.facade.TargetDefinition) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 2 with Repository

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.

the class LocalMetadataRepositoryTest method testOutdatedIndex.

@Test
public void testOutdatedIndex() throws CoreException {
    // create and fill repo
    File location = new File("target/indexmetadataRepo");
    LocalMetadataRepository repository = createRepository(location);
    InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
    iud.setId("test");
    iud.setVersion(Version.parseVersion("1.0.0"));
    iud.setProperty(RepositoryLayoutHelper.PROP_GROUP_ID, "group");
    iud.setProperty(RepositoryLayoutHelper.PROP_ARTIFACT_ID, "artifact");
    iud.setProperty(RepositoryLayoutHelper.PROP_VERSION, "version");
    IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
    repository.addInstallableUnits(Arrays.asList(iu));
    repository = (LocalMetadataRepository) loadRepository(location);
    // check: the artifact is in the index
    TychoRepositoryIndex metaIndex = createMetadataIndex(location);
    Assert.assertFalse(metaIndex.getProjectGAVs().isEmpty());
    // delete artifact from file system
    deleteDir(new File(location, "group"));
    // create a new repo and check that the reference was gracefully removed from the index
    repository = (LocalMetadataRepository) loadRepository(location);
    repository.save();
    metaIndex = createMetadataIndex(location);
    Assert.assertTrue(metaIndex.getProjectGAVs().isEmpty());
}
Also used : InstallableUnitDescription(org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) TychoRepositoryIndex(org.eclipse.tycho.p2.repository.TychoRepositoryIndex) FileBasedTychoRepositoryIndex(org.eclipse.tycho.repository.local.index.FileBasedTychoRepositoryIndex) File(java.io.File) Test(org.junit.Test)

Example 3 with Repository

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.

the class LocalArtifactRepository method loadMaven.

private void loadMaven() {
    final ArtifactsIO io = new ArtifactsIO();
    TychoRepositoryIndex index = localRepoIndices.getArtifactsIndex();
    for (final GAV gav : index.getProjectGAVs()) {
        try {
            File localArtifactFileLocation = contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS, RepositoryLayoutHelper.EXTENSION_P2_ARTIFACTS);
            if (!localArtifactFileLocation.exists()) {
                // if files have been manually removed from the repository, simply remove them from the index (bug 351080)
                index.removeGav(gav);
            } else {
                final InputStream is = new FileInputStream(contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS, RepositoryLayoutHelper.EXTENSION_P2_ARTIFACTS));
                try {
                    final Set<IArtifactDescriptor> gavDescriptors = io.readXML(is);
                    for (IArtifactDescriptor descriptor : gavDescriptors) {
                        internalAddDescriptor(descriptor);
                    }
                } finally {
                    is.close();
                }
            }
        } catch (IOException e) {
            // TODO throw properly typed exception if repository cannot be loaded
            e.printStackTrace();
        }
    }
    descriptorsOnLastSave = new HashSet<IArtifactDescriptor>(descriptors);
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ArtifactsIO(org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO) TychoRepositoryIndex(org.eclipse.tycho.p2.repository.TychoRepositoryIndex) IOException(java.io.IOException) GAV(org.eclipse.tycho.p2.repository.GAV) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 4 with Repository

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.

the class ReactorRepositoryManagerTest method testTargetPlatformComputationInIntegration.

@Test
public void testTargetPlatformComputationInIntegration() throws Exception {
    subject = getService(ReactorRepositoryManagerFacade.class);
    ReactorProject currentProject = new ReactorProjectStub("reactor-artifact");
    TargetPlatformConfigurationStub tpConfig = new TargetPlatformConfigurationStub();
    tpConfig.addP2Repository(new MavenRepositoryLocation(null, ResourceUtil.resourceFile("repositories/launchers").toURI()));
    subject.computePreliminaryTargetPlatform(currentProject, tpConfig, new ExecutionEnvironmentConfigurationStub("JavaSE-1.7"), null, null);
    ReactorProjectIdentities upstreamProject = new ReactorProjectIdentitiesStub(ResourceUtil.resourceFile("projectresult"));
    subject.computeFinalTargetPlatform(currentProject, Arrays.asList(upstreamProject));
    P2TargetPlatform finalTP = (P2TargetPlatform) currentProject.getContextValue("org.eclipse.tycho.core.TychoConstants/targetPlatform");
    Collection<IInstallableUnit> units = finalTP.getInstallableUnits();
    // units from the p2 repository
    assertThat(units, hasItem(unitWithId("org.eclipse.equinox.launcher")));
    // units from the upstream project
    assertThat(units, hasItem(unitWithId("bundle")));
    assertThat(units, hasItem(unitWithId("bundle.source")));
// TODO get artifact
}
Also used : ReactorRepositoryManagerFacade(org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade) TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) MavenRepositoryLocation(org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation) ReactorProjectIdentitiesStub(org.eclipse.tycho.test.util.ReactorProjectIdentitiesStub) ReactorProject(org.eclipse.tycho.ReactorProject) ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 5 with Repository

use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.Repository in project tycho by eclipse.

the class ModuleArtifactRepository method getInternalDescriptorForAdding.

@Override
protected ModuleArtifactDescriptor getInternalDescriptorForAdding(IArtifactDescriptor descriptor) throws IllegalArgumentException {
    if (descriptor == null) {
        throw new NullPointerException();
    } else if (!(descriptor instanceof ModuleArtifactDescriptor) || descriptor.getRepository() != this) {
        throw new IllegalArgumentException("Cannot add artifact descriptor which has not been created by this repository");
    }
    ModuleArtifactDescriptor internalDescriptor = (ModuleArtifactDescriptor) descriptor;
    try {
        MavenRepositoryCoordinates coordinates = internalDescriptor.getMavenCoordinates();
        artifactsMap.addToAutomaticLocation(coordinates.getClassifier(), coordinates.getExtension());
    } catch (ProvisionException e) {
        // TODO 393004 Revise exception handling
        throw new RuntimeException(e);
    }
    return internalDescriptor;
}
Also used : MavenRepositoryCoordinates(org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) ModuleArtifactDescriptor(org.eclipse.tycho.repository.module.ModuleArtifactRepository.ModuleArtifactDescriptor)

Aggregations

File (java.io.File)11 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)10 IOException (java.io.IOException)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)5 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)5 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)5 Test (org.junit.Test)5 GAV (org.eclipse.tycho.p2.repository.GAV)4 TychoRepositoryIndex (org.eclipse.tycho.p2.repository.TychoRepositoryIndex)4 TargetDefinition (org.eclipse.tycho.p2.target.facade.TargetDefinition)4 FileInputStream (java.io.FileInputStream)3 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)3 MavenRepositoryLocation (org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation)3 DestinationRepositoryDescriptor (org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor)3 RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)3 InputStream (java.io.InputStream)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2