Posted by inder
on May 22, 2008 at 4:37 PM PDT
In this blog, I discuss how to teach maven2 to compile the source-code present in directories in addition to src/main/java.
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.
Finally, I did find a solution for Maven2 in this and this thread, and thought I would share it here. Essentially, you define an include section in your build section of
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.