yannick1976
yannick1976

Reputation: 11565

Best way to extend eclipse Java project wizard?

I am writing an eclipse plug-in and I need to provide a functionality to let the user create a custom project which is basically a plain old Java project with my jar as a dependency and my sample class in the source folder.

It should also have my custom nature (this is to tag the project / change its icon so that it stands out visually).

The user must be able to choose at least the name of the project and its location, and preferably the Java execution environment because it must be 8+.

My understanding is the way to do this is to create a custom org.eclipse.ui.newWizards extension point. I have considered following solutions :

  1. Extending org.eclipse.jdt.internal.ui.wizards.JavaProjectWizard, to just add my jar, class and custom nature at creation. Problem is this class is "not API" and I should not be extending it.
  2. Create a basic wizard with just project name and location (and maybe Java environment combo box), and add Java project settings myself (java nature, source and output locations...). This is now my preferred option, but I'm wondering how simple it is to do it ? If I just add Java nature, I guess all associated preferences for the project will appear automatically...?
  3. Project doesn't really have special behavior, so a an Example wizard might do.

What would be the best solution in your opinion?

Upvotes: 3

Views: 918

Answers (1)

greg-449
greg-449

Reputation: 111142

As you mention you should not use JavaProjectWizard as this is an internal class and may be changed without notices.

You can use org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard to create a project. This does not let you change the wizard pages but you can override the performFinish to do the additional operations you need.

Adding the Java nature to the project will indeed make the various Java preference pages available.

Upvotes: 1

Related Questions