Search in sources :

Example 6 with TychoRepositoryIndex

use of org.eclipse.tycho.p2.repository.TychoRepositoryIndex 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 7 with TychoRepositoryIndex

use of org.eclipse.tycho.p2.repository.TychoRepositoryIndex 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

TychoRepositoryIndex (org.eclipse.tycho.p2.repository.TychoRepositoryIndex)7 File (java.io.File)5 GAV (org.eclipse.tycho.p2.repository.GAV)4 IOException (java.io.IOException)3 IArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor)3 ArtifactsIO (org.eclipse.tycho.p2.maven.repository.xmlio.ArtifactsIO)2 FileBasedTychoRepositoryIndex (org.eclipse.tycho.repository.local.index.FileBasedTychoRepositoryIndex)2 Test (org.junit.Test)2 BufferedOutputStream (java.io.BufferedOutputStream)1 FileInputStream (java.io.FileInputStream)1 FileOutputStream (java.io.FileOutputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 HashSet (java.util.HashSet)1 Artifact (org.apache.maven.artifact.Artifact)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 IArtifactKey (org.eclipse.equinox.p2.metadata.IArtifactKey)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)1 ArtifactDescriptor (org.eclipse.equinox.p2.repository.artifact.spi.ArtifactDescriptor)1