Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Efficient dev cycle with Maven, Tomcat/Glassfish, Archetype?

So far i've been using tomcat and glassfish to develop a testing webapp, without maven. And the usual development-till-deploy cycle is simple :

  1. develop in eclipse ide, with a WebContent folder, which is the root webapp folder that has the WEB-INF, web.xml, WEB-INF/lib, n all. The compiled classes location in eclipse is set to WEB-INF/classes.

  2. after coding, i could just click on the reload button in glassfish admin console for that specific webapp. In tomcat, i believe it's reload also in the tomcat manager.

  3. i could access the web application in the browser

Now if i would like to create a new webapp, that'll make use of latest stuffs of jsf, spring, jpa, hibernate, postgresql :

  1. what recommendation of archetype should i use in the creation of the project ?

  2. can i still use my previous steps of development? because i think it's very easy without having to repackage everything into a war file, or copying it into the tomcat's webapp folder everytime i want to test. Saving the files in eclipse, hit on the reload in the admin console / tomcat manager, and i could instantly test the updated webapp.

Or what do you usually do in the webapp development cycle ? Please share your experiences, =)

Thank you !

like image 570
Albert Gan Avatar asked Jan 11 '11 14:01

Albert Gan


1 Answers

Development Cycle with Maven and Friends

  1. Use Maven to drive your code-build-test-deploy-release cycle.
  2. Start with Maven Archetype that suits closest to your web-app. This will create the whole folder structure for you and will add Jar depencies.
  3. Use an embeded light-weight server like Jetty, this will be very fast on dev machine without sucking resources and is highly configurable. Plus, you can set it to auto-reload changes.
  4. Most of Maven project are supposed to be test-driven. Of which Maven takes care of using it's surefire plug-in. So, every build will have a test phase.
  5. You can define multiple profile for various environments (test, dev, prod, Win, Unix..). These profile will alter the behaviour of the project to be compatible with the environment.
  6. Use Cargo, again a Maven plugin to deploy your builds on test or production server, which can be Glassfish, Tomcat, Jetty or any oter webserver.
  7. Use Liquibase with or without Maven :) to manage your database changes the same way you manage your code change.

I came from almost similar project as yours in my previous company. Development with Maven makes things so smooth and the change is appreciable.


A little Google search shows that someone has worked on archetypes for JSF and JPA with Spring


Edit#1 -- added more details

Feasibility and Ease of Use

  • Maven is born out of neccessity to simplify the dev process for large and distributed code.
  • Maven is very well integrated with Eclipse -- so it's painless.
  • Jetty keeps monitoring source folders, so your changes gets deployed almost immediately.
  • You can customize the build to skip tests, to not build dependecies. When you just edit a UI component, Jetty will silently copy it to "target" folder.
  • If you're worried about copying and redeploying. You must read THIS to see how efficiently things are done, keeping in mind that you don't have to compile-test-deploy everytime you change a JSP or HTML.

That said, I would like to mention that Maven might be a challanging learning. This is an object oriented way of development cycle, to say. Most of us, who are used to build script, can find a bit tedious/verbose initially.

Resources

I would suggest to go through the following resources

  • Maven Book - Maven basics
  • Automated Deployment with Maven - going the whole nine yards If you can, literally follow this pattern.
  • Maven 2 Effective Implementation -- this book really helped us a lot.
like image 103
Nishant Avatar answered Nov 15 '22 03:11

Nishant