Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » Project Creation Requires Restart
Project Creation Requires Restart [message #253185] Mon, 05 May 2008 23:52
Eclipse UserFriend
Any ideas why I have to restart eclipse after using a plugin to
create/setup a project that uses custom builders? The custom builders
don't work correctly (code that is part of the plugin jar is not found)
until the environment reloads, after which the builders work perfectly.
The following is the code to setup the project...

final IProject project =
ResourcesPlugin.getWorkspace().getRoot().getProject(projectN ame);

WorkspaceModifyOperation operation = new WorkspaceModifyOperation() {
protected void execute(IProgressMonitor monitor) throws CoreException {
monitor.beginTask("", 2000);

try {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProjectDescription description =
workspace.newProjectDescription(project.getName());
String binName =
PreferenceConstants.getPreferenceStore().getString(Preferenc eConstants.SRCBIN_BINNAME);
String srcName =
PreferenceConstants.getPreferenceStore().getString(Preferenc eConstants.SRCBIN_SRCNAME);
IClasspathEntry[] entries = new IClasspathEntry[srcName == null ? 1 :
2];
IJavaProject javaProject;
String[] prevNatures;
String[] newNatures;
ICommand[] commands;
ICommand[] newCommands;

description.setLocation(null);

prevNatures = description.getNatureIds();
newNatures = new String[prevNatures.length + 2];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length]= JavaCore.NATURE_ID;
newNatures[prevNatures.length + 1]= JefNature.NATURE_ID;
description.setNatureIds(newNatures);

commands = description.getBuildSpec();
newCommands = new ICommand[commands.length + 2];
System.arraycopy(commands, 0, newCommands, 0, commands.length);
newCommands[commands.length] = description.newCommand();
newCommands[commands.length].setBuilderName(JavaCore.BUILDER _ID);
newCommands[commands.length + 1] = description.newCommand();
newCommands[commands.length + 1].setBuilderName(MyBuilder.BUILDER_ID);
description.setBuildSpec(newCommands);

project.create(description, new SubProgressMonitor(monitor, 1000));

if(monitor.isCanceled()) {
throw new OperationCanceledException();
}//if//

project.open(IResource.BACKGROUND_REFRESH, new
SubProgressMonitor(monitor, 1000));
javaProject = JavaCore.create(project);
entries[0] =
JavaCore.newContainerEntry(JavaRuntime.newDefaultJREContaine rPath());

if(srcName != null) {
createFolder(project.getFolder(srcName));
entries[1] =
JavaCore.newSourceEntry(project.getFullPath().append(srcName ));
}

if(binName != null) {
createFolder(project.getFolder(binName));
javaProject.setOutputLocation(project.getFullPath().append(b inName),
null);
}

javaProject.setRawClasspath(entries, new NullProgressMonitor());
}//try//
finally {
monitor.done();
}//finally//
}//execute()//
};

try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().run(tru e, true,
operation);
}
catch(Throwable e) {}
Previous Topic:JDT Refactoring Participants?
Next Topic:Possible bug in launch configuration
Goto Forum:
  


Current Time: Sun Jun 01 21:12:22 EDT 2025

Powered by FUDForum. Page generated in 0.03191 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top