Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 352436

Summary: Add option to setup API tools when converting a project to a plug-in project
Product: [Eclipse Project] PDE Reporter: Dani Megert <daniel_megert>
Component: UIAssignee: Curtis Windatt <curtis.windatt.public>
Status: VERIFIED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: curtis.windatt.public, Michael_Rennie, Olivier_Thomann
Version: 3.7   
Target Milestone: 3.8 M3   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
Fix to add option to conversion wizard none

Description Dani Megert CLA 2011-07-19 06:55:06 EDT
3.7 + http://wiki.eclipse.org/JDT/Eclipse_Java_7_Support_%28BETA%29

Needs to be investigated as maybe the Java 7 support broke it.

Steps:
1. start new workspace with 1.5 JRE
2. install Environment Descriptions in Eclipse and set it to 'Error'. I installed them from: http://download.eclipse.org/eclipse/updates/3.7
3. paste this into Package Explorer:
    public void test() {
    	StringBuilder b= new StringBuilder();
    	b.toString();
    }
4. convert the project to a PDE project
5. add this to the manifest:
Bundle-RequiredExecutionEnvironment: J2SE-1.4
==> no error reported (see comment below)
6. change the compliance of the project to 1.5 but leave the JRE as is
==> no error reported

I might even argue that the error should already be reported after step 5, as the diagnosis comes from PDE and hence should give more weight to the manifest entry than the project compliance. But once the compliance is set to 1.4 the error should definitely appear.
Comment 1 Olivier Thomann CLA 2011-07-19 11:29:14 EDT
I'll take a look.
Comment 2 Olivier Thomann CLA 2011-07-19 12:22:51 EDT
If in step 5a, you convert the project to use API Tools then errors are properly detected. Converting to a PDE project doesn't make it API Tools aware. Maybe we should add an extra checkbox in the wizard to convert to a PDE project identical to the check when creating a new PDE project.

I would close as INVALID.
Comment 3 Dani Megert CLA 2011-07-20 02:17:20 EDT
(In reply to comment #2)
> If in step 5a, you convert the project to use API Tools then errors are
> properly detected. Converting to a PDE project doesn't make it API Tools aware.
Indeed. Verified that it works when doing said step.

> Maybe we should add an extra checkbox in the wizard to convert to a PDE project
> identical to the check when creating a new PDE project.
Definitely. When I see a "normal" Java project I can only convert it to a Plug-in Project. After doing that I would expect that all preferences under the 'Plug-in Development' take effect. Note that I also looked on the project property page but no luck to enable API Tools there either.

We should
1. improve the wizard as you suggested
2. add a checkbox to the 'Plug-in Development' project property page
   [ ] Enable API Tools.
   This will also easily allow to see whether API Tools is enabled for a project,
   which is currently not the case. It would also allow to easily disable this
   again, which again, is currently not possible via UI as 'API Tools Setup...'
   is a one way action.
Comment 4 Olivier Thomann CLA 2011-07-20 12:39:04 EDT
Move to PDE/UI
Comment 5 Michael Rennie CLA 2011-07-20 12:53:13 EDT
(In reply to comment #3)
> 2. add a checkbox to the 'Plug-in Development' project property page
>    [ ] Enable API Tools.
>    This will also easily allow to see whether API Tools is enabled for a
> project,
>    which is currently not the case. It would also allow to easily disable this
>    again, which again, is currently not possible via UI as 'API Tools Setup...'
>    is a one way action.

I like this idea. We could even consider getting rid of the menu action altogether in this case. We would also have a decent fix for bug 221913 at the same time.
Comment 6 Olivier Thomann CLA 2011-07-20 12:54:31 EDT
(In reply to comment #5)
> I like this idea. We could even consider getting rid of the menu action
> altogether in this case. We would also have a decent fix for bug 221913 at the
> same time.
Yes, if we go ahead with this idea inside the PDE property page, then we should get rid of the menu.
Comment 7 Curtis Windatt CLA 2011-09-15 17:42:57 EDT
Created attachment 203458 [details]
Fix to add option to conversion wizard
Comment 8 Curtis Windatt CLA 2011-09-16 12:19:40 EDT
The conversion wizard still only can do the same basic operation as the creation wizard, which is to add the api tools nature to the project.  This does not perform a true api tools project setup.

Adding a checkbox to the PDE property page will suffer from the same problem.  Since API Tools sits higher on the stack, PDE cannot add/remove the builder, create a description file, etc.

Possible solutions would be to add the checkbox to an API tools property page or use a preference to store and add a listener for it in API Tools.
Comment 9 Michael Rennie CLA 2011-09-16 12:39:51 EDT
(In reply to comment #8)
> Possible solutions would be to add the checkbox to an API tools property page
> or use a preference to store and add a listener for it in API Tools.

The preference sounds like a good way for API tools to hook into the process. The biggest challenge I see is that we will lose the ability to convert component.xml files to API javadoc tags.
Comment 10 Curtis Windatt CLA 2011-09-19 16:52:39 EDT
I have pushed the attached patch which solves the problem as described.  I also updated the conversion tests to check that the nature is added successfully. Adding a check box to property page adds additional complexity and discussion should be held on bug 221913.

Marking as FIXED.
Comment 11 Curtis Windatt CLA 2011-09-21 12:57:04 EDT
Had to make an additional change to the conversion to add the java nature before adding the api tools nature.  This was causing a test failure in pde ui.

http://git.eclipse.org/c/pde/eclipse.pde.ui.git/commit/?id=c216e256565d2957ef646810f183d7247ba69bc5
Comment 12 Dani Megert CLA 2011-10-03 08:44:35 EDT
Works nicely, except that my choice is not stored i.e. I have to check the checkbox every time I convert a project. Filed bug 359701 for that.

I also fixed the string
Enable API Analy&sis ==> Enable API analy&sis
in HEAD.
Comment 13 Curtis Windatt CLA 2011-10-25 14:31:37 EDT
Works well for me and bug reporter. Verified in I20111021-1625