}
@Override
public Result execute(UIExecutionContext context)
{
Coordinate coordinate = project.getFacet(MetadataFacet.class).getOutputDependency().getCoordinate();
try
{
// TODO Project builder should support clean and install in the native API.
project.getFacet(PackagingFacet.class).createBuilder().addArguments("clean", "install").build();
}
catch (BuildException e)
{
return Results.fail("Unable to execute project build", e);
}
try
{
AddonId id = AddonId.from(coordinate.getGroupId() + ":" + coordinate.getArtifactId(), coordinate.getVersion());
RemoveRequest removeRequest = addonManager.remove(id);
removeRequest.perform();
Addons.waitUntilStopped(registry.getAddon(id));
InstallRequest installRequest = addonManager.install(id);
installRequest.perform();
return Results.success("Addon " + coordinate.toString() + " was installed succesfully.");
}
catch (Throwable t)
{
return Results.fail("Addon " + coordinate.toString() + " could not be installed.", t);
}
}