Bug 143025 - [build path] Derived attribute on default output folder of Java project doesn't work
Summary: [build path] Derived attribute on default output folder of Java project doesn...
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.3 RC1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-22 13:45 EDT by James Synge CLA
Modified: 2007-05-15 07:41 EDT (History)
5 users (show)

See Also:
Olivier_Thomann: review+


Attachments
ui fix (3.73 KB, patch)
2007-04-26 11:17 EDT, Benno Baumgartner CLA
no flags Details | Diff
ui fix (3.76 KB, patch)
2007-04-26 11:20 EDT, Benno Baumgartner CLA
no flags Details | Diff
proposed core fix (1.54 KB, patch)
2007-05-04 13:32 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Synge CLA 2006-05-22 13:45:57 EDT
When I create a new Java project, I configure it with separate source and output folders (src and bin).  The code that creates the output folder (BuildPathsBlock.flush) sets the derived attribute on the folder, but when I check the folder's properties later, the folder is not marked as derived.  This means that when I shared the project (commit to CVS), the bin folder is going to be added to the repository.

If I create Main.java in the default (unnamed) package, the corresponding class file, "project/bin/Main.class" is marked as derived.

If I create an empty, top-level package (e.g. "dummy"), the corresponding directory, "project/bin/dummy", is marked as derived.

My expectation was that the derived attribute would be set in the properties of the bin folder, and that the folder would not be shared with CVS.

Setting the component to UI, but I don't have any confidence that is correct.

FYI, tested with 3.2 RC4.
Comment 1 Martin Aeschlimann CLA 2006-05-22 17:53:17 EDT
Is jdt.core setting the derived flag back?
Comment 2 Dani Megert CLA 2006-05-23 05:20:21 EDT
NOTE: same behavior in 3.1.x
Comment 3 Jerome Lanneluc CLA 2006-05-23 05:47:00 EDT
Kent, can you please comment ?
Comment 4 Kent Johnson CLA 2006-05-23 13:25:24 EDT
I believe we have had this discussion before and the conclusion was that the user asked for the output folder, just as he asked for the corresponding source folder. The UI creates the output folder when the user asks for it so it should NOT be considered a derived folder and is not set as derived by the UI.

The builder only creates the output folder if it was deleted (see NameEnvironment.computeClasspathLocations()), but definitely marks ALL generated package folders and .class files as derived since they are generated by the builder.

So what's the problem?
Comment 5 Dani Megert CLA 2006-05-23 14:58:48 EDT
>So what's the problem?
Well, not sure whether this is caused by JDT Core or JDT UI but when I add/define the output folder via "Java Build Path" properties' "Source" page the output folder is marked as derived. I would expect that the derived flag is the same for both scenarios.
Comment 6 Kent Johnson CLA 2006-05-23 15:12:24 EDT
Well when I created my test project using the UI and chose separate src/output folders -> the output folder was not derived.

But it was marked as derived when I deleted the src/bin folders and added them back using the Build properties page.

The UI should at least be consistent when it creates the output folder.

Moving back to JDT/UI
Comment 7 James Synge CLA 2006-05-23 15:18:26 EDT
I didn't debug the JDT project creation code, but it certainly looks on the surface as if it does set the derived attribute on the bin directory (even if that isn't what was agreed to).  Perhaps somewhere else the derived mark is cleared?

Why should this matter you ask?  If I use an external tool as part of the build, and it places files into the bin directory, I think they should be considered derived too.  They would be if the bin directory is marked as derived, but not otherwise.
Comment 8 Martin Aeschlimann CLA 2006-05-24 03:26:32 EDT
I tried to reproduce the scenario, but couldn't. What are the steps?

In jdt.ui we create the output folder as derived. I don't know the discussions behind it, but at any case jdt.core and jdt.ui should be consistent.
Comment 9 James Synge CLA 2006-05-24 09:51:20 EDT
Steps to reproduce in RC4:

File > New > Project
Choose "Java Project"
Click Next
Enter Project Name ("foobar" in this example)
Choose "Create new project in workspace"
Choose "Create separate source and output folders"
Click Finish

In the Navigator view, choose foobar/bin
Right-click and choose "Properties"

You will see that bin is not derived.
Comment 10 Martin Aeschlimann CLA 2006-06-24 18:00:08 EDT
You're right, in this case we leave it to jdt.core to create the output folder (project.setRawClasspath(..)) 

I personally think it should be created as derived. When we in jdt.ui create a output folder, we create it derived.

jdt.core, please decide.
Comment 11 Olivier Thomann CLA 2006-10-10 21:56:13 EDT
Maxime,

It seems that the output folder following the steps in comment 9 should be created as derived.
Comment 12 Maxime Daniel CLA 2007-04-02 08:00:23 EDT
Following the steps of comment #9 with 3.3 I20070327-0800, the output directory is created by JDT UI with:
Thread [ModalContext] (Suspended (breakpoint at line 118 in Folder))	
	Folder.create(boolean, boolean, IProgressMonitor) line: 118	
	CoreUtility.createFolder(IFolder, boolean, boolean, IProgressMonitor) line: 57	
	JavaProjectWizardSecondPage.updateProject(IProgressMonitor) line: 209	
	JavaProjectWizardSecondPage.performFinish(IProgressMonitor) line: 358	
	JavaProjectWizard.finishPage(IProgressMonitor) line: 59	
	NewElementWizard$2.run(IProgressMonitor) line: 116	
	BatchOperation.executeOperation() line: 39	
	BatchOperation(JavaModelOperation).run(IProgressMonitor) line: 720	
	Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 1797	
	JavaCore.run(IWorkspaceRunnable, ISchedulingRule, IProgressMonitor) line: 4421	
	WorkbenchRunnableAdapter.run(IProgressMonitor) line: 87	
	ModalContext$ModalContextThread.run() line: 113	

Folder#create(boolean...) method calls Folder#create(int...) without the DERIVED flag, hence the folder gets created as not derived.

I do not believe that we explicitly change that afterwards on the JDT Core side (Kent pls correct me if I'm wrong), hence I'd contend this is a UI call.

Moving back to JDT UI for comments.
Comment 13 Martin Aeschlimann CLA 2007-04-02 08:47:43 EDT
You are right, there is code that creates output folders but doesn't set them as derived.
e.g. 
JavaProjectWizardSecondPage.updateProject(IProgressMonitor).folder
and probably also
BuildPathsBlock line 797

I don't know if that was always there, or got introduced later.

Benno, can you go through that and make sure that all output folders JDT UI creates are marked as derived?
JDT.Core, it is my understanding that also IProject.setRawClasspath also creates output folderd as derived.
Comment 14 Benno Baumgartner CLA 2007-04-26 11:17:47 EDT
Created attachment 65049 [details]
ui fix

Create all output folders as derived in JDT/UI.
Comment 15 Benno Baumgartner CLA 2007-04-26 11:20:43 EDT
Created attachment 65051 [details]
ui fix
Comment 16 Benno Baumgartner CLA 2007-04-26 11:26:21 EDT
Patch released > I20070424-0930

Move to core:
setRawClasspath does not (at least in some cases) create the output folder as derived:
1. Right click on a source folder in pkt expl
2. Build Path>Configure Output Folder...
3. Specific output folder
4. FooBar
5. OK
6. Go to Navigator view
7. Properties on FooBar
IS:
 Not derived
Should:
 Be derived

This folder is created by core, we set the raw classpath in: org.eclipse.jdt.internal.corext.buildpath.ClasspathModifier.commitClassPath(CPJavaProject, IProgressMonitor)
Comment 17 Kent Johnson CLA 2007-05-04 13:32:19 EDT
Created attachment 65945 [details]
proposed core fix
Comment 18 Olivier Thomann CLA 2007-05-07 14:06:39 EDT
Patch looks good.
Comment 19 Kent Johnson CLA 2007-05-08 13:24:16 EDT
Released into HEAD for 3.3RC1

Added BuildpathTests testMissingOutputFolder()
Comment 20 David Audel CLA 2007-05-15 07:41:43 EDT
Verified for 3.3RC1 using I20070515-0010