I downloaded a sample JSF 2 project called guessNumber.
I can compile and build the war file for this project. But when I try to move webapp from src/main/to WebContent/ it failed to compile: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode)
Why the conventional structure of the project is not working for maven? Do I have to place all java code, xhtml files and conf files all under src/ directory?
Maven is very particular about its directory structure, and trying to get it to use a different structure usually results in too many headaches. I have found the best way to convert non-Maven apps to Maven is to create a new Maven project from an appropriate archetype and then copy the files from the original project to the proper locations.
If that doesn't help, please post the original source directory layout and we can help you convert that to a Maven-styled layout.
reubin haz wrote:
Then do I have to follow maven's convention for the directory structure?
You'll have a world of annoyances if you don't. Also you'll be giving up one of Maven's strengths. While you may have a good and sufficient standard project layout for your shop, Maven's project layout standards are known everywhere. I can hand a Maven project over to anyone, and as long as they know Maven, they'll know immediately where to go to find things and work on them.
Don't feel alone, though. It took me a long time to reconcile myself to their standard layout, too.
Incidentally, one of the best ways to create a new Maven project is to spawn one using an archetype. You can also create your own archetypes if you have a site-specific project architecture(s) that you use a lot.
Customer surveys are for companies who didn't pay proper attention to begin with.
Since you are using Eclipse, make sure you install the m2eclipse plugin. Also, when you create a project, make sure you create a Maven Project. You can then select an archetype appropriate to your project.
Byt the way, there is no WebContent directory in Maven projects. Instead, web content goes into src/main/webapp. Also, Java source files go in src/main/java.