Skip to content

Commit

Permalink
Select best matching target environment for p2install
Browse files Browse the repository at this point in the history
Currently a p2 provisioned install always use the running target to
provision what is also the best option most of the time. In case where
there is no matching one this can lead to failing installs.

This now allows to specify the environments and shows a warning if the
running one does not has any match.
  • Loading branch information
laeubi committed Nov 24, 2023
1 parent a6dfcba commit c9d39c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,10 @@ private EquinoxInstallation createProvisionedInstallation() throws MojoExecution
} else {
installationBuilder.setDestination(work);
}
return installationBuilder.install();
List<TargetEnvironment> list = getTestTargetEnvironments();
TargetEnvironment env = list.isEmpty() ? runningEnvironment : list.get(0);
getLog().info("Provisioning with environment " + env + "...");
return installationBuilder.install(env);
} catch (Exception ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ public void setInstallFeatures(boolean installFeatures) {
this.installFeatures = installFeatures;
}

public EquinoxInstallation install() throws Exception {
public EquinoxInstallation install(TargetEnvironment main) throws Exception {
validate();
publishPlainBundleJars();
executeDirector();
executeDirector(main);
return new ProvisionedEquinoxInstallation(effectiveDestination, bundleReader);
}

Expand All @@ -121,7 +121,7 @@ private void publishPlainBundleJars() throws Exception {
artifactRepos.add(bundlesRepoURI);
}

private void executeDirector() throws MojoFailureException {
private void executeDirector(TargetEnvironment env) throws MojoFailureException {
DirectorRuntime.Command command = directorRuntime.newInstallCommand();
command.addMetadataSources(metadataRepos);
command.addArtifactSources(artifactRepos);
Expand All @@ -131,7 +131,7 @@ private void executeDirector() throws MojoFailureException {
command.setDestination(effectiveDestination);
command.setProfileName(profileName);
command.setInstallFeatures(installFeatures);
command.setEnvironment(TargetEnvironment.getRunningEnvironment());
command.setEnvironment(env);
log.info("Installing IUs " + ius + " to " + effectiveDestination);
try {
command.execute();
Expand Down

0 comments on commit c9d39c3

Please sign in to comment.