Community
Participate
Working Groups
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.
Is jdt.core setting the derived flag back?
NOTE: same behavior in 3.1.x
Kent, can you please comment ?
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?
>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.
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
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.
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.
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.
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.
Maxime, It seems that the output folder following the steps in comment 9 should be created as derived.
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.
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.
Created attachment 65049 [details] ui fix Create all output folders as derived in JDT/UI.
Created attachment 65051 [details] ui fix
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)
Created attachment 65945 [details] proposed core fix
Patch looks good.
Released into HEAD for 3.3RC1 Added BuildpathTests testMissingOutputFolder()
Verified for 3.3RC1 using I20070515-0010