use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class MirrorApplicationServiceImpl method createMirrorApplication.
private static MirrorApplication createMirrorApplication(RepositoryReferences sources, DestinationRepositoryDescriptor destination, IProvisioningAgent agent, boolean includePacked) {
final MirrorApplication mirrorApp = new MirrorApplication(agent, includePacked);
List<RepositoryDescriptor> sourceDescriptors = createSourceDescriptors(sources);
for (RepositoryDescriptor sourceDescriptor : sourceDescriptors) {
mirrorApp.addSource(sourceDescriptor);
}
mirrorApp.addDestination(createDestinationDescriptor(destination));
return mirrorApp;
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences 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.tools.RepositoryReferences in project tycho by eclipse.
the class DirectorMojo method execute.
// TODO extract methods
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
List<Product> products = getProductConfig().getProducts();
if (products.isEmpty()) {
getLog().info("No product definitions found. Nothing to do.");
}
DirectorRuntime director = getDirectorRuntime();
RepositoryReferences sources = getSourceRepositories();
for (Product product : products) {
for (TargetEnvironment env : getEnvironments()) {
DirectorRuntime.Command command = director.newInstallCommand();
File destination = getProductMaterializeDirectory(product, env);
String rootFolder = product.getRootFolder(env.getOs());
if (rootFolder != null && rootFolder.length() > 0) {
destination = new File(destination, rootFolder);
}
command.addMetadataSources(sources.getMetadataRepositories());
command.addArtifactSources(sources.getArtifactRepositories());
command.addUnitToInstall(product.getId());
for (DependencySeed seed : product.getAdditionalInstallationSeeds()) {
command.addUnitToInstall(seed);
}
command.setDestination(destination);
command.setProfileName(ProfileName.getNameForEnvironment(env, profileNames, profile));
command.setEnvironment(env);
command.setInstallFeatures(installFeatures);
getLog().info("Installing product " + product.getId() + " for environment " + env + " to " + destination.getAbsolutePath());
try {
command.execute();
} catch (DirectorCommandException e) {
throw new MojoFailureException("Installation of product " + product.getId() + " for environment " + env + " failed", e);
}
}
}
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class TestMojo method createProvisionedInstallation.
private EquinoxInstallation createProvisionedInstallation() throws MojoExecutionException {
try {
TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
createSurefireProperties(provider);
ProvisionedInstallationBuilder installationBuilder = provisionedInstallationBuilderFactory.createInstallationBuilder();
Set<Artifact> testHarnessArtifacts = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
for (Artifact testHarnessArtifact : testHarnessArtifacts) {
installationBuilder.addBundleJar(testHarnessArtifact.getFile());
}
RepositoryReferences sources = repositoryReferenceTool.getVisibleRepositories(project, session, RepositoryReferenceTool.REPOSITORIES_INCLUDE_CURRENT_MODULE);
installationBuilder.addMetadataRepositories(sources.getMetadataRepositories());
installationBuilder.addArtifactRepositories(sources.getArtifactRepositories());
installationBuilder.setProfileName(profileName);
installationBuilder.addIUsToBeInstalled(getIUsToInstall(testHarnessArtifacts));
File workingDir = new File(project.getBuild().getDirectory(), "p2temp");
workingDir.mkdirs();
installationBuilder.setWorkingDir(workingDir);
installationBuilder.setDestination(work);
return installationBuilder.install();
} catch (Exception ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class RepositoryReferenceTool method addTargetPlatformRepository.
/**
* Restores the p2 metadata view on the module's build target platform that was calculated
* during the initial dependency resolution (see
* org.eclipse.tycho.p2.resolver.P2ResolverImpl.toResolutionResult(...)).
*/
private void addTargetPlatformRepository(RepositoryReferences sources, MavenSession session, MavenProject project) throws MojoExecutionException, MojoFailureException {
try {
File repositoryLocation = new File(project.getBuild().getDirectory(), "targetPlatformRepository");
repositoryLocation.mkdirs();
FileOutputStream stream = new FileOutputStream(new File(repositoryLocation, "content.xml"));
try {
MetadataSerializable serializer = osgiServices.getService(MetadataSerializable.class);
TargetPlatform targetPlatform = TychoProjectUtils.getTargetPlatform(project);
DependencyResolver resolver = dependencyResolverLocator.lookupDependencyResolver(project);
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration();
DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project, targetPlatform, DefaultReactorProject.adapt(session), resolverConfiguration);
// this contains dependency-only metadata for 'this' project
Set<Object> targetPlatformInstallableUnits = new HashSet<>(dependencyArtifacts.getInstallableUnits());
for (ArtifactDescriptor artifact : dependencyArtifacts.getArtifacts()) {
ReactorProject otherProject = artifact.getMavenProject();
if (otherProject == null) {
// can't really happen
continue;
}
File artifactXml = otherProject.getArtifact(RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS);
if (artifactXml != null && artifactXml.isFile()) {
sources.addArtifactRepository(artifactXml.getParentFile());
}
}
serializer.serialize(stream, targetPlatformInstallableUnits);
} finally {
stream.close();
}
sources.addMetadataRepository(repositoryLocation);
} catch (IOException e) {
throw new MojoExecutionException("I/O exception while writing the build target platform to disk", e);
}
}
Aggregations