Teaching Maven2 to use multiple source directories
For project Gson, which is a library to convert Java objects to JSON and vice-versa, we use Maven2. We are also using Javacc to generate a JSON parser, but we had to modify the generated source-code to hide the generated classes. This meant that we had two source directories, one under
src/main/java and another under
src/generated/java. I tried hard to find out how to convince maven to use both the directories for compilation, but most websites really advise you to use multiple modules. In maven1.x, there seemed to be some support for it through
maven:addPath but nothing in Maven2.
See pom.xml of Gson for more details.
Have you run into a similar issue? Did you also find the answer hard to search? How did you solve this problem? Share your thoughts as comments to this blog. Thanks for reading.