Skip to main content



      Home
Home » Newcomers » Newcomers » Eclipse builder not working
Eclipse builder not working [message #516269] Tue, 23 February 2010 08:04 Go to next message
Eclipse UserFriend
Hello all,

I created a plugin for eclipse with a custom builder. Somehow the custom builder doesnt work. It does get added to the project if you start one, but when you invoke a build, it wont use the build of the custom builder.

Here is what ive done in sort of pseudo code,

- plugin.xml, add a Nature and a Builder.
- Created class Nature and Builder
- Nature configure function adds the builder to the project.
- wizard for creating a project add a nature to the project (which on his turn adds the builder like stated above).

So when i start the plugin, and i create a new project with the above mentioned wizard, the builder gets properly added to the project (project->properties->builders show ok same as .project file)

But when i edit a file in my plugin and hit the safe button, auto build gets done, but it doesnt get into the build function in my custom builder...

I use maven 2, anybody know if maven might be blocking something?

If u need any code examples lemme know, but im pretty sure i did everything fine since the builder is added when i create a new project in my plugin.


Greetz

[Updated on: Tue, 23 February 2010 08:31] by Moderator

Re: Eclipse builder not working [message #516491 is a reply to message #516269] Wed, 24 February 2010 03:50 Go to previous messageGo to next message
Eclipse UserFriend
Guess after ~70 views and no reply, you might need some code examples, mibbe you can detect something is wrong, here we go:

Plugin.xml:
<extension id="GigaspacesBuilder" name="Gigaspaces Builder" point="org.eclipse.core.resources.builders">
	<builder hasNature="true">
		<run class="org.openspaces.ide.eclipse.builders.GigaspacesBuilder" />
	</builder>
</extension>
<extension id="GigaspacesNature" name="Gigaspaces Nature" point="org.eclipse.core.resources.natures">
	<builder id="org.openspaces.eclipse.plugin.ProjectBuilder" />
	<runtime>
		<run class="org.openspaces.ide.eclipse.natures.GigaspacesNature" />
	</runtime>
</extension>


Example of the builder:
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) {
	System.out.println("Calling the build of the Gigaspaces Builder");
	if (kind == IncrementalProjectBuilder.FULL_BUILD) {
		fullBuild(monitor);
	} else {
		IResourceDelta delta = getDelta(getProject());
		if (delta == null) {
			fullBuild(monitor);
		} else {
			incrementalBuild(delta, monitor);
		}
	}
	return null;
}

private void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) {
	System.out.println("incremental build on " + delta);
	try {
		delta.accept(new IResourceDeltaVisitor() {
		        public boolean visit(IResourceDelta delta) {
				System.out.println("changed: " + delta.getResource().getRawLocation());
				return true; // visit children too
			}
		});
	} catch (CoreException e) {
		e.printStackTrace();
	}
}


Calls to add builder and nature to project:
GigaSpacesCoreUtils.addProjectNature(project, GigaspacesNature.NATURE_ID, monitor);
GigaSpacesCoreUtils.addProjectBuilder(project, GigaspacesBuilder.BUILDER_ID, monitor);



And finally the functions that really add the builder and nature to the project:
public static void addProjectNature(IProject project, String nature, IProgressMonitor monitor) throws CoreException {
	if (project != null && nature != null) {
		if (!project.hasNature(nature)) {
			IProjectDescription desc = project.getDescription();
				
				String[] oldNatures = desc.getNatureIds();
				String[] newNatures = new String[oldNatures.length + 1];
				newNatures[0] = nature;
				if (oldNatures.length > 0) {
					System.arraycopy(oldNatures, 0, newNatures, 1, oldNatures.length);
				}
				desc.setNatureIds(newNatures);
				project.setDescription(desc, monitor);
			}
		}
	}
}

public static void addProjectBuilder(IProject project, String builderID, IProgressMonitor monitor) throws CoreException {
	IProjectDescription desc = project.getDescription();
	ICommand builderCommand = getProjectBuilderCommand(desc, builderID);
	if (builderCommand == null) {

		// Add a new build spec
		ICommand command = desc.newCommand();
		command.setBuilderName(builderID);

		// Commit the spec change into the project
		addProjectBuilderCommand(desc, command);
		project.setDescription(desc, monitor);
	}
}



Well i hope this gives u some more insight and i might get a response, like i said when i start the plugin and create a new project with my own wizard it does add the builder to the project:



Like i said the image shows the builder is added to the project, same counts for the nature, but somehow the build method of my custom builder doesnt get invoked by eclipse, not if i full build, not if i auto build...

Any ideas?

[Updated on: Wed, 24 February 2010 03:58] by Moderator

Re: Eclipse builder not working [message #516510 is a reply to message #516269] Wed, 24 February 2010 04:58 Go to previous message
Eclipse UserFriend
This topic can be closed, i got it working, there was a typo in the plugin.xml...

Anyway if u need an example of how to make a builder, its on the previous post Smile

Greetz
Previous Topic:[solved] Really basic deployment question
Next Topic:[solved] Really basic forum question
Goto Forum:
  


Current Time: Wed Aug 13 16:53:19 EDT 2025

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

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

Back to the top