tags:

views:

79

answers:

2

I'm new to Maven and have skimmed over the documentation as I am following the Hibernate tutorial at http://docs.jboss.org/hibernate/stable/core/reference/en/html_single/#tutorial-firstapp-mvn.

I have installed Maven and successfully setup a web-app but this does not contain all of the standard directories mentioned in the tutorial. Am I going mad?

When building my Maven project I am using the maven-archetype-webapp. This gives me the arh-webapp\src\main\resources and arh-webapp\src\main\webapp directories but I'm missing quite a few directories mentioned on the link http://maven.apache.org/guides/introduction/introduction-to-the-standard-directory-layout.html.

Surely I don't have to manually add these? If not then the Hibernate documentation does not mention what archetype to use in order to achieve the directory structure used in their tutorial. Please can someone enlighten me.

What archetype do I need to use in order to have the above directory plus the src/main/java directory? If there is no such archetype then can easily append these using Maven? and how?

A: 

Surely you'll have to manually add these.

Just create those directories that according to the Maven convention are missing. Remember, a Maven Archetype is just a starting point to save you time configuring your workspace. After encountering many problems in some Archetypes myself I've been accustomed to just use a basic-web-app-archetype and then customize it myself, as a beginner with Maven you'll be better off doing that, and will learn a lot.

Regards.

StudiousJoseph
Cheers StudiousJoseph. Appreciate the advise. Good to know that someone else has experienced problems. I realise that I could add these directories myself but I have noticed that using the standard archetype I can generate the other directories missing from the web archetype build. I'm wondering whether there is a archetype that combines both standard directory structures. I suppose I'm asking a lot. I struggle to see the point of Maven if I can not achieve my goal easily. :-)
AndyRED
Here http://docs.codehaus.org/display/MAVENUSER/Archetypes+List is a list of Maven archetypes. Try to see if any of those actually accomplish what you're looking for in your app :)
StudiousJoseph
Thanks again. Time to do some serious reading I think :-)
AndyRED
A: 

Not all the directories mentioned are required for your standard web application. In fact, the reason behind the presence of the src/main/java, src/main/resources and the src/main/webapp directories is due to the archetype that you've used.

IMHO, the book titled "Better Builds with Maven" will serve you better; the Sonatype books on Maven might also help. The complete Maven documentation is also available as a PDF file, for future reference.

But just in case, you need some clarity on the terms used, here's some:

Archetype: A pattern for projects. Simple web applications (with no dependencies on other frameworks/libraries) have their own archetypes, so do applications using Spring, Hibernate, Seam, etc. Some archetypes will result in creation of different directories, as they are coded that way. You might be able to change the directory structures in most cases, although I cannot vouch for every archetype. For instance, it is quite possible to place your sources in 'src' instead of 'src/main/java', although this requires additional configuration in the POM.

Lifecycles, Phases and Goals: A Maven build lifecycle is a series of phases, with each phase executing a set of goals. Maven can be commanded to execute a build phase, which results in execution of all phases until and including the specified phase.

Maven plugins: Maven plugins contain one or more goals. Goals need not be bound to phases, but usually you would bind them to particular phases. Plugins are the basis for everything operational in Maven; you're using plugins even though you are just compiling the application (the Maven compiler plugin is a core plugin that is present in the Maven distribution).

I hope the above helps, but I would suggest that the reference books be followed.

Vineet Reynolds
Hi Vineet ReynoldsAppreciate the documentation references. I found the following link has answered my question: http://maven.apache.org/guides/mini/guide-creating-archetypes.html. I need to build the descriptor which includes my additional directories. I will set this up tomorrow as I have spent too much time on this tonight already :-)
AndyRED