What are the reasons for putting the generated files in a tree parallel to the source trees? For example, in Eclipse I usually choose to put the sources to
.../src and the compiler generated files in
.../classes. Mixing both in a single tree looks dirty to me, however I can't find any advantage in the separation:
- Theoretically, I could backup the sources more easily, but that's not true. I'm using git and ignoring all
*.classfiles everywhere is just trivial. With other version control systems it should be very easy, too.
- Theoretically, it helps to find a given source file faster as the tree is not polluted by the class files. Actually, I seldom need it (the IDE offers much faster ways). For looking at the classes I'm using the Class View, which abstracts from the directory structure.
- Theoretically, there may be tools requiring that, but I'm not aware of any.
There's two disadvantages of the separation:
- The IDE copies all non-java files ("resources") from the source tree to the generated one. If the IDE doesn't notice a changed resource, then there's an old version on the classpath (i.e., in the generated tree) and I'll find myself running a program working with the old version... this may cost me quite a lot of time.
- Once upon a time, I need to find the class-file corresponding with a given java-file (or vice versa), which takes quite a lot of time.
So what are the real advantages of the separation?
This question is not Java (Eclipse) specific. However, in Java the problem of navigating to a parallel tree is aggravated by the fact that the trees tend to be very deep (because of the directory structure mirroring the package structure and because of the world-wide package naming convention).