Search in sources :

Example 11 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class TargetPlatformFactoryTest method testIncludeLocalMavenRepo.

@Test
public void testIncludeLocalMavenRepo() throws Exception {
    TestResolverFactory factory = new TestResolverFactory(logVerifier.getLogger());
    LocalMetadataRepository localMetadataRepo = factory.getLocalMetadataRepository();
    // add one IU to local repo
    localMetadataRepo.addInstallableUnit(InstallableUnitUtil.createIU("locallyInstalledIU", "1.0.0"), new GAV("test", "foo", "1.0.0"));
    subject = factory.getTargetPlatformFactoryImpl();
    Collection<IInstallableUnit> iusIncludingLocalRepo = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, null).getInstallableUnits();
    tpConfig.setForceIgnoreLocalArtifacts(true);
    Collection<IInstallableUnit> iusWithoutLocalRepo = subject.createTargetPlatform(tpConfig, NOOP_EE_RESOLUTION_HANDLER, null, null).getInstallableUnits();
    Set<IInstallableUnit> retainedIUs = new HashSet<>(iusIncludingLocalRepo);
    retainedIUs.removeAll(iusWithoutLocalRepo);
    assertEquals(1, retainedIUs.size());
    assertEquals("locallyInstalledIU", retainedIUs.iterator().next().getId());
}
Also used : IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) LocalMetadataRepository(org.eclipse.tycho.repository.local.LocalMetadataRepository) GAV(org.eclipse.tycho.p2.repository.GAV) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 12 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class P2MetadataGeneratorImplTest method gav.

@Test
public void gav() throws Exception {
    P2GeneratorImpl impl = new P2GeneratorImpl(false);
    impl.setBuildPropertiesParser(new BuildPropertiesParserForTesting());
    File location = new File("resources/generator/bundle").getCanonicalFile();
    String groupId = "org.eclipse.tycho.p2.impl.test";
    String artifactId = "bundle";
    String version = "1.0.0-SNAPSHOT";
    List<TargetEnvironment> environments = new ArrayList<>();
    DependencyMetadata metadata = impl.generateMetadata(new ArtifactMock(location, groupId, artifactId, version, PackagingType.TYPE_ECLIPSE_PLUGIN), environments);
    List<IInstallableUnit> units = new ArrayList<>(metadata.getInstallableUnits());
    List<IArtifactDescriptor> artifacts = new ArrayList<>(metadata.getArtifactDescriptors());
    Assert.assertEquals(1, units.size());
    IInstallableUnit unit = units.iterator().next();
    Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", unit.getId());
    Assert.assertEquals("1.0.0.qualifier", unit.getVersion().toString());
    Assert.assertEquals(2, unit.getRequirements().size());
    Assert.assertEquals(1, artifacts.size());
    IArtifactDescriptor ad = artifacts.iterator().next();
    Assert.assertEquals("org.eclipse.tycho.p2.impl.test.bundle", ad.getArtifactKey().getId());
    Assert.assertEquals("1.0.0.qualifier", ad.getArtifactKey().getVersion().toString());
    Assert.assertEquals(groupId, ad.getProperties().get(RepositoryLayoutHelper.PROP_GROUP_ID));
    Assert.assertEquals(artifactId, ad.getProperties().get(RepositoryLayoutHelper.PROP_ARTIFACT_ID));
    Assert.assertEquals(version, ad.getProperties().get(RepositoryLayoutHelper.PROP_VERSION));
}
Also used : IArtifactDescriptor(org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor) ArrayList(java.util.ArrayList) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) P2GeneratorImpl(org.eclipse.tycho.p2.impl.publisher.P2GeneratorImpl) BuildPropertiesParserForTesting(org.eclipse.tycho.test.util.BuildPropertiesParserForTesting) DependencyMetadata(org.eclipse.tycho.p2.impl.publisher.DependencyMetadata) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) File(java.io.File) Test(org.junit.Test)

Example 13 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class PomDependencyProcessor method collectPomDependencies.

PomDependencyCollector collectPomDependencies(MavenProject project, Collection<Artifact> transitivePomDependencies) {
    final TychoRepositoryIndex p2ArtifactsInLocalRepo = localRepoIndices.getArtifactsIndex();
    PomDependencyCollector result = resolverFactory.newPomDependencyCollector();
    result.setProjectLocation(project.getBasedir());
    for (Artifact artifact : transitivePomDependencies) {
        if (Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) {
            // ignore
            continue;
        }
        P2DataArtifacts p2Data = new P2DataArtifacts(artifact);
        p2Data.resolve(session, project.getRemoteArtifactRepositories());
        if (p2Data.p2MetadataXml.isAvailable() && p2Data.p2ArtifactsXml.isAvailable()) {
            /*
                 * The POM dependency has (probably) been built by Tycho, so we can re-use the
                 * existing p2 data in the target platform. The data is stored in the attached
                 * artifacts p2metadata.xml and p2artifacts.xml, which are now present in the local
                 * Maven repository.
                 */
            if (logger.isDebugEnabled()) {
                logger.debug("P2TargetPlatformResolver: Using existing metadata of " + artifact.toString());
            }
            result.addArtifactWithExistingMetadata(new ArtifactFacade(artifact), new ArtifactFacade(p2Data.p2MetadataXml.artifact));
            /*
                 * Since the p2artifacts.xml exists on disk, we can add the artifact to the (global)
                 * p2 artifact repository view of local Maven repository. Then, the artifact is
                 * available in the build.
                 */
            // TODO this should happen in resolution context
            p2ArtifactsInLocalRepo.addGav(new GAV(artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion()));
        } else if (!p2Data.p2MetadataXml.isAvailable() && !p2Data.p2ArtifactsXml.isAvailable()) {
            /*
                 * The POM dependency has not been built by Tycho. If the dependency is a bundle,
                 * run the p2 bundle publisher on it and add the result to the resolution context.
                 */
            if (logger.isDebugEnabled()) {
                logger.debug("P2resolver.addMavenArtifact " + artifact.toString());
            }
            result.publishAndAddArtifactIfBundleArtifact(new ArtifactFacade(artifact));
        } else {
            failDueToPartialP2Data(artifact, p2Data);
        }
    }
    return result;
}
Also used : PomDependencyCollector(org.eclipse.tycho.p2.target.facade.PomDependencyCollector) TychoRepositoryIndex(org.eclipse.tycho.p2.repository.TychoRepositoryIndex) ArtifactFacade(org.eclipse.tycho.p2.facade.internal.ArtifactFacade) GAV(org.eclipse.tycho.p2.repository.GAV) Artifact(org.apache.maven.artifact.Artifact)

Example 14 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class RepositoryLayoutHelperTest method testRelpathSimpleGroupId.

@Test
public void testRelpathSimpleGroupId() {
    GAV gav = new GAV("a", "b", "1.0.0");
    Assert.assertEquals("a/b/1.0.0/b-1.0.0.jar", RepositoryLayoutHelper.getRelativePath(gav, null, null));
}
Also used : GAV(org.eclipse.tycho.p2.repository.GAV) Test(org.junit.Test)

Example 15 with GAV

use of org.eclipse.tycho.p2.repository.GAV in project tycho by eclipse.

the class UpdateLocalIndexMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    LocalRepositoryP2Indices localRepoIndices = serviceFactory.getService(LocalRepositoryP2Indices.class);
    GAV gav = new GAV(project.getGroupId(), project.getArtifactId(), project.getArtifact().getVersion());
    TychoRepositoryIndex artifactsIndex = localRepoIndices.getArtifactsIndex();
    TychoRepositoryIndex metadataIndex = localRepoIndices.getMetadataIndex();
    try {
        addGavAndSave(gav, artifactsIndex);
        addGavAndSave(gav, metadataIndex);
    } catch (IOException e) {
        throw new MojoExecutionException("Could not update local repository index", e);
    }
}
Also used : LocalRepositoryP2Indices(org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) TychoRepositoryIndex(org.eclipse.tycho.p2.repository.TychoRepositoryIndex) IOException(java.io.IOException) GAV(org.eclipse.tycho.p2.repository.GAV)

Aggregations

GAV (org.eclipse.tycho.p2.repository.GAV)15 IOException (java.io.IOException)6 File (java.io.File)5 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)5 FileInputStream (java.io.FileInputStream)4 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)4 TychoRepositoryIndex (org.eclipse.tycho.p2.repository.TychoRepositoryIndex)4 Test (org.junit.Test)4 ArtifactsIO (org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO)3 BufferedOutputStream (java.io.BufferedOutputStream)2 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 MetadataIO (org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO)2 MavenRepositoryCoordinates (org.eclipse.tycho.p2.repository.MavenRepositoryCoordinates)2 BufferedReader (java.io.BufferedReader)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1 OutputStream (java.io.OutputStream)1 OutputStreamWriter (java.io.OutputStreamWriter)1 Writer (java.io.Writer)1