use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.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;
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.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);
}
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.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();
}
}
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.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;
}
use of org.eclipse.tycho.p2.resolver.TargetDefinitionFile.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);
}
Aggregations