Reputation: 1
I develop Eclipse plugin which should programmatically create Ant Builder for specified project.
The same way as using UI: Properties->Builders->New->Ant Builder.
I tried to find solution several weeks but without success. Could anybody help me?
Upvotes: 0
Views: 515
Reputation: 21
Following might not be the cleanest way of doing what you are asking, but works. This adds a builder called "MyBuilderName" to the project's builders. You then need to create a file called "MyBuilderName.launch" under the folder .externalToolBuilders under the project folder.
Make an Ant builder and check the file in .externalToolBuilders folder to see what it should look like.
...
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
ICommand[] newcommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newcommands, 1, commands.length);
ICommand command = desc.newCommand();
command.setBuilderName(
"org.eclipse.ui.externaltools.ExternalToolBuilder");
command.setArguments(
Collections.singletonMap("LaunchConfigHandle",
"<project>/.externalToolBuilders/MyBuilderName"));
newcommands[0] = command;
desc.setBuildSpec(newcommands);
project.setDescription(desc, monitor);
...
Upvotes: 1