aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes project structure for maven 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "project structure for maven 2" Watch "project structure for maven 2" New topic
Author

project structure for maven 2

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
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?

Thanks


SCJA, SCJP5.0, SCBCD, SCWCD
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

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.


JBoss In Action
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
Thanks for the reply. I do not have an existing project that wanna use maven to compile and build. I want to create a new project by using that sample guessNumber project as the starting point.

I use Eclipse to create a new project, then I copied guessNumber files inside src/
WebContent/ is created by Eclipse with empty META-INF/ and WEB-INF/ inside

Then maven works so far. But when I tried to move the the webapp/ directory to the conventional place, WebContent/ it failed.

Then do I have to follow maven's convention for the directory structure?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15641
    
  15

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.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5772
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: project structure for maven 2
 
Similar Threads
New to ant - Compilation failure
Creating a build and deployable using Ant
help needed for building ejb project with maven
Using Own Directory Structure in Maven
How to mavenize a project