Bug 356714 - Clear the previous generation directory when a new one is set
Summary: Clear the previous generation directory when a new one is set
Status: NEW
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: EDT (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Tony Chen CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-05 05:19 EDT by Tony Chen CLA
Modified: 2017-02-23 14:20 EST (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tony Chen CLA 2011-09-05 05:19:45 EDT
If we do not clear the previous one, for JavaGen, there will be two copies of Java Files which the same name. We probably should delete the previous directory and anything inside it. The other option might be to exclude the previous directory from Java Source folder. However, I could not think of a good reason to keep the files in the previous directory.
Comment 1 Matt Heitz CLA 2011-09-06 10:06:26 EDT
Should we warn the user about this?  A dialog could tell them what's about to happen, and ask if they want to continue.
Comment 2 Justin Spadea CLA 2011-09-06 10:19:38 EDT
Is this going to only delete the generated files? What if I generated into a source folder that contained some hand-written code?
Comment 3 Tony Chen CLA 2011-10-08 03:15:00 EDT
Is there a way to know if a file (say .java) is generated by our JavaGenerator or is written by user?
Comment 4 Justin Spadea CLA 2011-10-10 09:10:09 EDT
There's no way to know by looking at a file if it was generated or hand-written. You could check what the generators for the files they would have created (IGenerator.getOutputFiles()). Right now our own generators only return a single file for this method, we'd have to update the Java generator to also return the *.eglsmap file.

You'd have to be smart about this, in that you only check for generated artifacts corresponding to resources that have had their generation directory changed. So if I change the generator at the project level, and one of the packages overrides the generation directory, that package's files do not get deleted.

Also, if we decide to do anything in 0.7.0, I agree with Matt that a yes/no dialog should be used.
Comment 5 Tony Chen CLA 2011-10-28 02:23:53 EDT
Based on the discussions, I think we should defer this work until we have a better solution and have good answers to the listed questions. For now, user will have to manually clean directories and files if they change output directory in compiler setting. 

Questions to be answered: 

1. There's not a good way to tell which files are generated by EDT and which are written by user (target java code of an externalType for example). Our generators know 

2. Since each resource can override generator setting. To determine if a directory is really not used as gen output directory, we have to scan configuration of all resources. And if we are changing the workspace default, we will have to scan all projects in the workspace. 

3. RBD & EDT don't delete generated files if the EGL source is deleted, I think we should make the rationale consistent in terms of cleaning generated artifacts which (we think) are not needed any more. 

4. Bottom line is that user should be aware of, and have an choice when something is going to be deleted.