| Summary: | APT should not create .apt_generated right away | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Yen Lu <yenlu> |
| Component: | APT | Assignee: | Generic inbox for the JDT-APT component <jdt-apt-inbox> |
| Status: | CLOSED WONTFIX | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | deboer, eclipse, jpitman |
| Version: | 3.3 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | stalebug | ||
|
Description
Yen Lu
This behavior is by design, and by painful experience with the other alternatives :-) We have to create the directory at config time, because it is not possible to create it on the fly within a build due to limitations in what resources can be changed. We have no way of knowing ahead of time whether or not the various processors installed on a project may want to generate files. One possibility, I suppose, would be to have an option in the project preferences to disable file generation. If that option were specified (either through the GUI or programmatically) then no processor would be allowed to generate files - either calls to the Filer interface would throw an exception or they would return no-op writers - and we could remove the .apt_generated directory. I would personally prefer not to implement that, because every time we've changed this code it's eaten up at least a month of effort on my part and broken something else along the way. But if there is a compelling reason, this could be reopened. Can you explain in more detail why you'd like this directory to not exist? Is it causing a problem? Walter, Thank you for the quick response. We have an annotations processor implementation that will never generate any files. When we register them on plain Java projects, the existence of .apt_generated makes the project more complex that what our users would expect (it is hidden but still on the project classpath). Would it be possible to create some kind of property on the annotations processor which the framework could then query to determine whether or not to create .apt_generated? I think if you spend some time contemplating how you would implement such a property (keeping in mind that processors can change; that a project may acquire multiple processors over time; that loading a processor may have side effects; and that changing the classpath can only be done outside of the context of a build) you will discover that getting this to work right is not trivial. I would be willing to review a patch, if you would like to submit one. Please realize, though, that since past experience has shown that changing this code causes problems, considerable testing is required. Perhaps there is something I'm not understanding about the problem your users are facing? From what you've said so far this doesn't seem like the best use of development time: the additional complexity introduced by adding an optional directory to the classpath doesn't seem excessive to me, but I admit to being biased. We don't have the resources at this point to do justice to this feature. Resolving as "won't fix", pending a more clear business case for this feature, or external contribution of a patch. Please feel free to reopen this bug and supply more detail, or a patch, if you feel this prioritization is incorrect. Annotation processors are used for more than just generating files, can also be used for validation etc. Some customers with existing Java projects will get upset if adding validation functionality changes the structure of their projects. The decision as to whether to create the directory doesn't have to be done during the build, but at the time an annotations processor is added to the project. A new attribute could be added to the "factories" element of the org.eclipse.jdt.apt.core.annotationProcessorFactory extension point to indicate if the directory should be created. The default would be true in order to preserve backward compatibility. When an annotations processor is enabled on a project, the directory would be created only if the attribute was true. If a project has more than one processor, then the directory is created if the attribute for any of those processors is true. For annotation processors which are not provided through a plugin, the existing behavior would be unchanged. Reopening per John's comments and suggestions. This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |