Search in sources :

Example 6 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.

the class DirectorMojo method getBuildOutputRepository.

private RepositoryReferences getBuildOutputRepository() {
    // TODO share "repository" constant?
    File buildOutputRepository = getBuildDirectory().getChild("repository");
    RepositoryReferences result = new RepositoryReferences();
    result.addMetadataRepository(buildOutputRepository);
    result.addArtifactRepository(buildOutputRepository);
    return result;
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) File(java.io.File)

Example 7 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.

the class StandaloneDirectorRuntimeFactory method installStandaloneDirector.

private void installStandaloneDirector(File installLocation, ArtifactRepository localMavenRepository) throws MojoExecutionException {
    // using the internal director...
    DirectorRuntime bootstrapDirector = osgiServices.getService(DirectorRuntime.class);
    try {
        // ... install from a zipped p2 repository obtained via Maven ...
        URI directorRuntimeRepo = URI.create("jar:" + getDirectorRepositoryZip(localMavenRepository).toURI() + "!/");
        DirectorRuntime.Command command = bootstrapDirector.newInstallCommand();
        command.addMetadataSources(Arrays.asList(directorRuntimeRepo));
        command.addArtifactSources(Arrays.asList(directorRuntimeRepo));
        // ... a product that includes the p2 director application ...
        command.addUnitToInstall("tycho-standalone-p2-director");
        command.setProfileName("director");
        // ... to a location in the target folder
        command.setDestination(installLocation);
        // there is only this environment in the p2 repository zip
        // TODO use a "no environment-specific units" setting
        command.setEnvironment(new TargetEnvironment("linux", "gtk", "x86_64"));
        logger.info("Installing a standalone p2 Director...");
        command.execute();
    } catch (DirectorCommandException e) {
        throw new MojoExecutionException("Could not install the standalone director", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) URI(java.net.URI) DirectorRuntime(org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)

Example 8 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.

the class AbstractMavenMetadataRepository method load.

protected void load() {
    MetadataIO io = new MetadataIO();
    for (GAV gav : metadataIndex.getProjectGAVs()) {
        try {
            File localArtifactFileLocation = contentLocator.getLocalArtifactLocation(gav, RepositoryLayoutHelper.CLASSIFIER_P2_METADATA, RepositoryLayoutHelper.EXTENSION_P2_METADATA);
            if (!localArtifactFileLocation.exists()) {
                // if files have been manually removed from the repository, simply remove them from the index (bug 351080)
                metadataIndex.removeGav(gav);
            } else {
                InputStream is = new FileInputStream(localArtifactFileLocation);
                try {
                    Set<IInstallableUnit> gavUnits = io.readXML(is);
                    unitsMap.put(gav, gavUnits);
                    units.addAll(gavUnits);
                } finally {
                    is.close();
                }
            }
        } catch (IOException e) {
            // TODO throw properly typed exception if repository cannot be loaded
            e.printStackTrace();
        }
    }
}
Also used : FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) MetadataIO(org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IOException(java.io.IOException) GAV(org.eclipse.tycho.p2.repository.GAV) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 9 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.

the class TargetPlatformFactoryImpl method createTargetPlatform.

/**
 * Computes the target platform from the given configuration and content.
 *
 * <p>
 * Used as entry point for tests, which can provide the execution environment configuration via
 * the more low-level type {@link ExecutionEnvironmentResolutionHandler}.
 * </p>
 *
 * @param tpConfiguration
 * @param eeResolutionHandler
 *            Representation of the target execution environment profile. In case of a custom EE
 *            profile, the handler also reads the full specification from the target platform.
 * @param reactorProjects
 *            may be <code>null</code>
 * @param pomDependencies
 *            may be <code>null</code>
 *
 * @see #createTargetPlatform(TargetPlatformConfigurationStub,
 *      ExecutionEnvironmentConfiguration, List, PomDependencyCollector)
 */
public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentResolutionHandler eeResolutionHandler, List<ReactorProject> reactorProjects, PomDependencyCollector pomDependencies) {
    List<TargetDefinitionContent> targetFileContent = resolveTargetDefinitions(tpConfiguration, eeResolutionHandler.getResolutionHints());
    PomDependencyCollectorImpl pomDependenciesContent = (PomDependencyCollectorImpl) pomDependencies;
    // TODO 412416 remove when the RepositoryBlackboardKey registration is gone
    if (pomDependenciesContent == null)
        pomDependenciesContent = new PomDependencyCollectorImpl(mavenContext);
    // TODO 372780 get rid of this special handling of pomDependency artifacts: there should be one p2 artifact repo view on the target platform
    IRawArtifactFileProvider pomDependencyArtifactRepo = pomDependenciesContent.getArtifactRepoOfPublishedBundles();
    RepositoryBlackboardKey blackboardKey = RepositoryBlackboardKey.forResolutionContextArtifacts(pomDependenciesContent.getProjectLocation());
    ArtifactRepositoryBlackboard.putRepository(blackboardKey, new ProviderOnlyArtifactRepository(pomDependencyArtifactRepo, Activator.getProvisioningAgent(), blackboardKey.toURI()));
    logger.debug("Registered artifact repository " + blackboardKey);
    Set<MavenRepositoryLocation> completeRepositories = tpConfiguration.getP2Repositories();
    registerRepositoryIDs(completeRepositories);
    // collect & process metadata
    boolean includeLocalMavenRepo = shouldIncludeLocallyInstalledUnits(tpConfiguration);
    LinkedHashSet<IInstallableUnit> externalUIs = gatherExternalInstallableUnits(completeRepositories, targetFileContent, pomDependenciesContent, includeLocalMavenRepo);
    Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(reactorProjects);
    List<TargetPlatformFilter> iuFilters = tpConfiguration.getFilters();
    TargetPlatformFilterEvaluator filter = !iuFilters.isEmpty() ? new TargetPlatformFilterEvaluator(iuFilters, logger) : null;
    applyConfiguredFilter(filter, reactorProjectUIs.keySet());
    applyFilters(filter, externalUIs, reactorProjectUIs.keySet(), eeResolutionHandler.getResolutionHints());
    PreliminaryTargetPlatformImpl targetPlatform = new // 
    PreliminaryTargetPlatformImpl(// 
    reactorProjectUIs, // 
    externalUIs, // 
    pomDependenciesContent.getMavenInstallableUnits(), // 
    eeResolutionHandler.getResolutionHints(), // 
    filter, // 
    localMetadataRepository, createExternalArtifactProvider(completeRepositories, targetFileContent, pomDependencyArtifactRepo, // 
    tpConfiguration.getIncludePackedArtifacts()), // 
    localArtifactRepository, // 
    includeLocalMavenRepo, logger);
    eeResolutionHandler.readFullSpecification(targetPlatform.getInstallableUnits());
    return targetPlatform;
}
Also used : IRawArtifactFileProvider(org.eclipse.tycho.repository.p2base.artifact.provider.IRawArtifactFileProvider) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) RepositoryBlackboardKey(org.eclipse.tycho.repository.registry.facade.RepositoryBlackboardKey) TargetPlatformFilterEvaluator(org.eclipse.tycho.p2.target.filters.TargetPlatformFilterEvaluator) MavenRepositoryLocation(org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation) ProviderOnlyArtifactRepository(org.eclipse.tycho.repository.p2base.artifact.repository.ProviderOnlyArtifactRepository) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) TargetPlatformFilter(org.eclipse.tycho.artifacts.TargetPlatformFilter)

Example 10 with Repository

use of org.eclipse.tycho.p2.target.facade.TargetDefinition.Repository in project tycho by eclipse.

the class P2DependencyResolver method computePreliminaryTargetPlatform.

@Override
public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects) {
    TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
    ExecutionEnvironmentConfiguration ee = TychoProjectUtils.getExecutionEnvironmentConfiguration(project);
    TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub();
    tpConfiguration.setIncludePackedArtifacts(configuration.isIncludePackedArtifacts());
    PomDependencyCollector pomDependencies = null;
    if (TargetPlatformConfiguration.POM_DEPENDENCIES_CONSIDER.equals(configuration.getPomDependencies())) {
        pomDependencies = collectPomDependencies(project, reactorProjects, session);
    } else {
        // TODO 412416 remove this when the setProjectLocation is no longer needed
        pomDependencies = resolverFactory.newPomDependencyCollector();
        pomDependencies.setProjectLocation(project.getBasedir());
    }
    for (ArtifactRepository repository : project.getRemoteArtifactRepositories()) {
        addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration);
    }
    tpConfiguration.setEnvironments(configuration.getEnvironments());
    for (File file : configuration.getTargets()) {
        addTargetFileContentToTargetPlatform(file, configuration.getTargetDefinitionIncludeSourceMode(), tpConfiguration);
    }
    tpConfiguration.addFilters(configuration.getFilters());
    return reactorRepositoryManager.computePreliminaryTargetPlatform(DefaultReactorProject.adapt(project), tpConfiguration, ee, reactorProjects, pomDependencies);
}
Also used : TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) ExecutionEnvironmentConfiguration(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration) PomDependencyCollector(org.eclipse.tycho.p2.target.facade.PomDependencyCollector) ArtifactRepository(org.apache.maven.artifact.repository.ArtifactRepository) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) File(java.io.File)

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