use of org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime 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.director.shared.DirectorRuntime 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);
}
}
Aggregations