views:

52

answers:

2

In my Eclipse project I'm using a third-party annotation processor, Hibernate Metamodel Generator to be exact. The annotation processor works as expected and generates .java files as specified by the spec. These files are generated into the directory of the Eclipse project under a "gen" folder. In the project properties this is correctly reflected since two source folders exist - "src" and "gen." However, when the project is built for some reason all the [generated] sources under "gen" are not compiled (checking the "bin" directory I only see .class files from the "src" directory). Does anyone know why this is happening?

+1  A: 

You will have to refresh the "gen" folder in Eclipse (e.g. from the Package Explorer) in order for Eclipse to see the newly generated files and compile them. Are you doing this?

David Sykes
yep, first thing i tried. the weird thing is eclipse says it doesn't recognize those files when i try to use them (red squiggly line and a message under Problems view), but when i get rid of the code that uses them and try to use auto-complete it shows the generated classes as an option. i also tried to clean and then rebuild the project. i feel like those java files are generated at the wrong time, as in first everything under src is compiled into bin, then the .java files are generated under gen. not sure if i can verify that very easily
Andrey
A: 

I figured it out a while ago and thought I'd come back and explain what happens. When the compiler is run it compiles the existing sources (the ones that I wrote) and then generates source files from the existing source files but it doesn't compile these generated classes. I ended up turning this into an Ant project (as per setup instructions). So, basically I had two tasks: first to generate new source files (running javac with the -proc:only option causes annotation processing to happen without compiling the sources) and the second to actually compile all sources (generated and existing).

Andrey