Bug 9765 - Choosing "Compute Build Path" causes java project to no longer build
Summary: Choosing "Compute Build Path" causes java project to no longer build
Status: RESOLVED FIXED
Alias: None
Product: PDE
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Wassim Melhem CLA
QA Contact:
URL:
Whiteboard:
Keywords: readme
Depends on:
Blocks:
 
Reported: 2002-02-13 15:39 EST by Alan Boxall CLA
Modified: 2003-02-15 18:43 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alan Boxall CLA 2002-02-13 15:39:15 EST
Take a java project that has been converted to a PDE project.

Open the plugin.xml and in the PDE views go to the "Dependancies" page.  RMB 
to "Compute Build Path".

After that my java project won't build.

Build 20020125
Comment 1 Dejan Glozic CLA 2002-02-13 17:33:22 EST
Could you define 'does not build'?

In addition, try moving up to 20020212 or at least 20020205.
Comment 2 Alan Boxall CLA 2002-02-13 19:01:49 EST
By build I mean it won't compile and generate .class files

I will try a more recent eclipse build.

In the meantime...

To reproduce:

1) Create a Java project
2) Go to the navigator and convert it to a PDE
3) Create a class that is in a package 
   > It will appear as a package in the packages view
4) Open the plugin.xml
5) Goto the dependancies page and RMB to "Compute Build Path"
6) Go to the packages view and the packages now look like folders! 

>> I have not found anyway to get it back to a proper Java project.  I can't 
build the java and I have to delete it and start over to get it back to a 
buildable java project.
Comment 3 Alan Boxall CLA 2002-02-13 19:55:33 EST
Just downloaded 20020212 and the problem is still there.

I see that there are more obvious ways to update the classpath.  Great work!!!
Comment 4 Karice McIntyre CLA 2002-03-11 12:36:47 EST
I've experienced similar problems in the feb 14 stable build.

I created my project as a java project, not a PDE project.  I guess when I 
created a plugin.xml file it automatically converted to PDE?

-On the Source tab of the Java build path property page for the project, my 
project specifies to use source folders called /src contained in the project.
-I also have added required plugins to the classpath (e.g. core, ui) by 
choosing Add Variable on the Libraries page.  e.g. 
ECLIPSE_HOME/plugins/org.eclipse.ui/workbench.jar
-I addes some jar files to my project to a directory <my-project>/lib

*When I do Compute Build Path from the Dependencies page in the plugin.xml 
editor (to get the jar files in <my-project>/lib to show up), my /src folder in 
the the build path is whacked.  It is gone when I check the Source tab of the 
Java Build Path page when I check the properties of my project.  
*AND the jar files that I added for my required plugins (ui, core, etc) by 
choosing Add Variable on the Libraries page are gone!!
Comment 5 Dejan Glozic CLA 2002-03-11 14:26:57 EST
Here is how build computation works:

1) Source entries are taken from library definitions in build.properties. These 
definitions connect source folders and the resulting JARs that will be built. 
For example, PDE has the following:

source.pde.jar = src/

The format is: source.<library name> = <comma-separated-list-of-source-folders>

2) If build.properties is missing, PDE preserves source entries that were 
already present on the build path.

3) Library entires are added for each plug-in library defined in the plugin.xml 
if present.

4) If binary projects are present in the workspace, PDE will add project 
references for all dependent plug-ins (in 'requires') that resolve as projects.

5) If not, PDE will add external JARs (using ECLIPSE_HOME variable) for all 
dependent plug-ins that resolve as external.

Something tells me that both Allan's and your problem are coming from 
build.properties that is not set up. In addition, do not add anything in 
your classpath manually (libraries etc.) - use plug-in dependency.
This may seem drastic, but adding JARs in your classpath will only
allow you to compile, not run, because plug-in loader will not be able
to find those classes. 
Comment 6 Peter Burka CLA 2002-03-15 18:19:46 EST
I've experienced the same problem in the 20020214 build.

Everytime I use 'Compute build path' I have to go back to the project's 
properties page and reset the source folder.
Comment 7 Dejan Glozic CLA 2002-03-15 18:22:27 EST
Have you tried what I suggested i.e. to specify your source folder?

You can do it from the manifest editor. Open plugin.xml using PDE manifest 
editor, switch to 'Runtime' page, select your library, and define source folder
(s) in the section below (use 'New' to choose the source folders from the 
workspace). PDE will update build.properties under the covers.
Comment 8 Dejan Glozic CLA 2002-03-15 18:48:45 EST
Based on the conversation with Peter, I think that the common root of this 
problem is the missing build.properties file.

This file is vital for PDE because it links source folders and libraries. It is 
necessary for the plug-in build and is also used for source portion of the 
classpath computation.

If this file is missing, it can be indirectly created as previously suggested. 
However, I realize that PDE is not very friendly in describing what is wrong 
with the build path. I am changing the priority to 'enhancement' to indicate 
that PDE should do something to warn about the problem and suggest steps to 
correct it.
Comment 9 Alan Boxall CLA 2002-03-18 11:39:03 EST
I tried to create the "build.properties" using the steps outlined in this bug.

Using the either the 2/14 stable build or the 3/14 integration build I got 
errors when I tried to update the "Library content" portion of the Runtime page.

Here is what I did.   My plugin has 2 .jar files.

NOTE: my project does not use "src/" for the project's source directory.

I selected one of the entries in the runtime library section of the "Runtime" 
page of the PDE editor and then pressed "New" on the "Library Content" section 
I get a small dialog that lets me choose a directory.  

1) if I choose a specific directory I get an error dialog "Cannot nest entry 
<path to entry I chose> inside <path to my plugin project>."
> in 20020214 an entry is added to this section
> in 20020314 nothing appears in this section

2) if I choose the top level project directory then I get a more severe error:
> driver 20020214 
java.lang.IllegalArgumentException: Path must include project and resource name.
	at org.eclipse.core.internal.resources.Workspace.newResource
(Workspace.java(Compiled Code))
	at org.eclipse.core.internal.resources.Workspace.newResource
(Workspace.java(Compiled Code))
	at org.eclipse.core.internal.resources.Container.getFolder
(Container.java:125)
	at 
org.eclipse.pde.internal.editor.manifest.JarsSection.verifyFolderExists
(JarsSection.java:324)
	at org.eclipse.pde.internal.editor.manifest.JarsSection.handleNew
(JarsSection.java:270)
	at org.eclipse.pde.internal.editor.manifest.JarsSection.access$4
(JarsSection.java:251)
	at org.eclipse.pde.internal.editor.manifest.JarsSection$4.widgetSelected
(JarsSection.java:190)
	at org.eclipse.swt.widgets.TypedListener.handleEvent
(TypedListener.java:85)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java(Compiled 
Code))
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:771)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:777)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:151)
	at org.eclipse.core.launcher.Main.run(Main.java:502)
	at org.eclipse.core.launcher.Main.main(Main.java:362)

> driver 20020314

java.lang.IllegalArgumentException: Path must include project and resource name.
	at org.eclipse.core.internal.resources.Workspace.newResource
(Workspace.java(Compiled Code))
	at org.eclipse.core.internal.resources.Workspace.newResource
(Workspace.java(Compiled Code))
	at org.eclipse.core.internal.resources.Container.getFolder
(Container.java(Compiled Code))
	at 
org.eclipse.pde.internal.editor.manifest.JarsSection.verifyFolderExists
(JarsSection.java:260)
	at org.eclipse.pde.internal.editor.manifest.JarsSection.handleNew
(JarsSection.java:197)
	at org.eclipse.pde.internal.editor.manifest.JarsSection.buttonSelected
(JarsSection.java:115)
	at 
org.eclipse.pde.internal.editor.TableSection$PartAdapter.buttonSelected
(TableSection.java:35)
	at 
org.eclipse.pde.internal.parts.SharedPartWithButtons$SelectionHandler.buttonSele
cted(SharedPartWithButtons.java:31)
	at 
org.eclipse.pde.internal.parts.SharedPartWithButtons$SelectionHandler.widgetSele
cted(SharedPartWithButtons.java:24)
	at org.eclipse.swt.widgets.TypedListener.handleEvent
(TypedListener.java:85)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java
(Compiled Code))
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:637)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java
(Compiled Code))
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java
(Compiled Code))
	at org.eclipse.ui.internal.Workbench.run(Workbench.java:675)
	at org.eclipse.core.internal.boot.InternalBootLoader.run
(InternalBootLoader.java:777)
	at org.eclipse.core.boot.BootLoader.run(BootLoader.java:319)
	at java.lang.reflect.Method.invoke(Native Method)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:151)
	at org.eclipse.core.launcher.Main.run(Main.java:502)
	at org.eclipse.core.launcher.Main.main(Main.java:362)

Comment 10 Alan Boxall CLA 2002-03-18 17:36:50 EST
It looks like the problem is how we have our Java project setup.

We don't use separate src/ bin/ directories but instead took the defaults you 
get when creating a Java project with is to put source and binaries in the 
project directory.

I am going to confirm that this is the case by attempting to convert my Java 
project to use src/ and bin/ directories.

This does point out a problem with anyone that creates a default Java project 
and subsequently converts it to a PDE.
Comment 11 Dejan Glozic CLA 2002-04-16 14:44:40 EDT
Java-to-PDE project conversion should handle a case where both source and 
binary files are directly in a Java project (no src/ and bin/ directories).
Comment 12 Dejan Glozic CLA 2002-04-16 16:19:55 EDT
This is a borderline P2 - may drop into P3 if no time.
Comment 13 Wassim Melhem CLA 2003-02-15 18:43:44 EST
Fixed in 2.1 M5.
During Java-PDE conversion, we handle both cases gracefully: source is in src 
folder or source directly under project.
Updating the classpath of projects to be converted retains all source folders 
already in the classpath.