this.logger = logger;
}
public void enableValidationBuilderAndCommand(IProject project, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
ICommand[] builders = description.getBuildSpec();
for (ICommand builder : builders) {
if (builder.getBuilderName().equals(VALIDATION_BUILDER_NAME)) {
logger.trace("Validation builder already installed, skipping");
return;
}
}
logger.trace("Installing validation builder");
ICommand[] newBuilders = new ICommand[builders.length + 1];
System.arraycopy(builders, 0, newBuilders, 0, builders.length);
ICommand validationCommand = description.newCommand();
validationCommand.setBuilderName(VALIDATION_BUILDER_NAME);
newBuilders[newBuilders.length - 1] = validationCommand;
description.setBuildSpec(newBuilders);
project.setDescription(description, monitor);
logger.trace("Installed validation builder");
}