use of org.erlide.engine.model.builder.BuilderTool in project erlide_eclipse by erlang.
the class ErlangEclipseBuilder method build.
@Override
public IProject[] build(final int kind, final Map<String, String> args, final IProgressMonitor monitor) throws CoreException {
final IProject project = getProject();
if (project == null || !project.isAccessible()) {
return null;
}
final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(project);
final ProjectConfigType config = erlProject.getConfigType();
final BuilderTool tool = erlProject.getBuilderProperties().getBuilderTool();
if (!validateBuildConfiguration(erlProject)) {
ErlLogger.warn("Builder tool and config mismatch: " + tool + " " + config);
monitor.setCanceled(true);
}
final ErlangBuilder builder = ErlangBuilderFactory.get(tool);
if (builder != null) {
final BuildNotifier notifier = new BuildNotifier(monitor, project);
if (builder instanceof InternalBuilder) {
// temporary hack; rebar builder will not need this
((InternalBuilder) builder).setDelta(getDelta(project));
}
builder.build(ErlangBuilder.BuildKind.get(kind), erlProject, notifier);
}
return null;
}
use of org.erlide.engine.model.builder.BuilderTool in project erlide_eclipse by erlang.
the class ErlangEclipseBuilder method validateBuildConfiguration.
private boolean validateBuildConfiguration(final IErlProject erlProject) {
final ProjectConfigType config = erlProject.getConfigType();
final BuilderTool tool = erlProject.getBuilderProperties().getBuilderTool();
if (!config.matchesTool(tool)) {
final String msg = String.format("Project's builder tool %s and configuration %s don't match", tool, config);
MarkerUtils.createProblemMarker(erlProject.getWorkspaceProject(), null, msg, 0, IMarker.SEVERITY_WARNING);
return false;
}
return true;
}
use of org.erlide.engine.model.builder.BuilderTool in project erlide_eclipse by erlang.
the class ProjectCreator method createProject.
public IProject createProject() throws CoreException {
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject newProjectHandle = workspace.getRoot().getProject(name);
if (newProjectHandle.exists()) {
throw new CoreException(Status.OK_STATUS);
}
final IProjectDescription description = workspace.newProjectDescription(name);
description.setLocationURI(location);
// // update the referenced project if provided
if (referencedProjects != null) {
description.setReferencedProjects(referencedProjects);
}
// create the new project operation
final IRunnableWithProgress op = new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException {
final CreateProjectOperation op1 = new CreateProjectOperation(description, WizardMessages.NewProject_windowTitle);
try {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=219901
// Making this undoable would be a bad idea
op1.execute(monitor, notifier);
newProjectHandle.open(monitor);
description.setNatureIds(new String[] { ErlangCore.NATURE_ID });
newProjectHandle.setDescription(description, null);
final BuilderTool builder = info.getBuilder();
ErlangNature.setErlangProjectBuilder(newProjectHandle, builder);
createBuilderConfig(builder);
createFolders(newProjectHandle, Lists.newArrayList(info.getOutputDir()), monitor);
createFolders(newProjectHandle, info.getSourceDirs(), monitor);
createFolders(newProjectHandle, info.getIncludeDirs(), monitor);
createConfig(newProjectHandle, info.getConfigType(), monitor);
final IErlProject erlProject = ErlangEngine.getInstance().getModel().getErlangProject(newProjectHandle);
erlProject.setConfigType(info.getConfigType());
final BuilderProperties builderProperties = new BuilderProperties();
builderProperties.setBuilderTool(builder);
builderProperties.setCompileTarget(info.getBuilderData().get("compile"));
builderProperties.setCleanTarget(info.getBuilderData().get("clean"));
erlProject.setBuilderProperties(builderProperties);
erlProject.setProperties(info);
} catch (final Exception e) {
throw new InvocationTargetException(e);
}
}
};
// run the new project creation operation
try {
context.run(false, true, op);
} catch (final InterruptedException e) {
return null;
} catch (final InvocationTargetException e) {
final Throwable t = e.getTargetException();
if (t instanceof ExecutionException && t.getCause() instanceof CoreException) {
final CoreException cause = (CoreException) t.getCause();
StatusAdapter status;
if (cause.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
status = new StatusAdapter(StatusUtil.newStatus(IStatus.WARNING, NLS.bind(WizardMessages.NewProject_caseVariantExistsError, newProjectHandle.getName()), cause));
} else {
status = new StatusAdapter(StatusUtil.newStatus(cause.getStatus().getSeverity(), WizardMessages.NewProject_errorMessage, cause));
}
status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, WizardMessages.NewProject_errorMessage);
StatusManager.getManager().handle(status, StatusManager.BLOCK);
} else {
final StatusAdapter status = new StatusAdapter(new Status(IStatus.WARNING, ErlideUIPlugin.PLUGIN_ID, 0, NLS.bind(WizardMessages.NewProject_internalError, t.getMessage()), t));
status.setProperty(IStatusAdapterConstants.TITLE_PROPERTY, WizardMessages.NewProject_errorMessage);
StatusManager.getManager().handle(status, StatusManager.LOG | StatusManager.BLOCK);
}
return null;
}
return newProjectHandle;
}
Aggregations