Question

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?

Was it helpful?

Solution

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).

OTHER TIPS

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?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top