• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best practise for Maven for Web Project

 
Luke Murphy
Ranch Hand
Posts: 300
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
~Hi,
In your standard Web Application, you have WebContent (HTML, .CSS, javascript and JSPs) and Java source files.

Is it best practise in maven to have one pom for your entire web project (webcontent + Java Source files) or to have one pom for your web content and then one for your javasource files.
Your Java source files then get packaged to a jar and your WebContent is packaged as a War which depends on the Java Source Files packaged as jar.

Many thanks.

 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I has always seen the servlets and their helper classes appearing in the same projects with the static web content. Thus the classes end up in WEB-INF/classes. In a way this makes more sense because usually the Java sources and the static content are closely related. If the Java classes were packaged in a separate JAR file, one would usually assume that that JAR could be used in multiple projects, which in this instances is not the case.

Anyway, that is my 2 cents.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18098
50
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unless I'm mistaken, you're considering a scenario where the static content of a webapp is being packaged and deployed separately from the dynamic stuff. JSPs, BTW are not static content - they're compiled into dynamic components, and therefore cannot be effectively deployed in a static content server.

There once was a practical performance reason for separating static and active services in J2EE, but that was long, long ago. Modern-day servers such as Tomcat can serve up CSS and HTML just as efficiently as Apache can, so there's no real reason to complicate matters by creating a separate static content bundle.

If you do choose to separate the 2, however, the "correct" way would be to make each package be a separate Maven project, since the Maven rule is 1 product output per project.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic