Tuesday, September 28, 2010

Maven, Grails, GWT and Spring MVC.

Maven has this concept of archetypes, which are in simple terms pre-configured or pre-setup projects for different technologies like GWT, Grails, Scala, Wicket etc. So what you are getting is Maven's goodness sprinkled on top of these pre configured project (which prefer a certain structure to things) so you can benefit from Maven while not having to integrate Maven by hand yourself.

The first archetype I tried was Grails archetype. I am actively working on a business idea using Grails so was curious to try grails archetype:

#1. Generate the grails based project:
mvn archetype:generate \
-DarchetypeGroupId=org.grails \
-DarchetypeArtifactId=grails-maven-archetype \
-DarchetypeVersion=1.2.2 \
-DgroupId=com.mayabansi.mavenisedgrails \
-DartifactId=MavenisedGrails

You have to provide the archetypeGroupId and archetypeArtifactId as is. I chose Grails version 1.2.2. You can chose which Grails version you want to use in archetypeVersion. At the time of this post, the following versions were available: grails-maven-archetypes

The groupId I chose is com.mayabansi (my company name) and mavnisedgrails is my project name. artifactId is my project name.

But, above will create a new Maven project with a POM and a standard Maven directory structure. What you won't see is anything that looks like a Grails application. So, the next step is to create the Grails project structure that you're used to:

#2. mvn initialize:

mvn initialize

Above command creates a complete Grails directory structure.

New posts about:

#1: Maven, Spring, Hibernate and Mockito

#2. Maven and Hibernate hell.

Sunday, September 5, 2010

My journey through Maven - 1

Recently I was at the Tampa Java Users Group (Tampa JUG) for a presentation on Maven. Although, I was introduced to Maven once earlier while working at Pentaho, this presentation was more "what-maven-is?" and "why-maven?". And, then I came across this post: What has maven ever done for us? which intrigued me even further. This post is the first in the series of posts on my initiation in maven!

So how do you install maven? I am using Linux Mint OS (a super cool Operating System that adds great UI and controls on top of Ubuntu), so the commands below basically are for Ubuntu based systems.

#1. apt-cache search maven
...
maven-debian-helper - Helper tools for building Debian packages with Maven
maven2 - Java software project management and comprehension tool
...

This gives you an idea about all the maven related packages in apt's cache.

#2. sudo apt-get install maven2

This installed maven2.2.1 on my system

#3. mvn -v
Apache Maven 2.2.1 (rdebian-1)
Java version: 1.6.0_20
Java home: /usr/lib/jvm/java-6-sun-1.6.0.20/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "2.6.31-20-generic" arch: "i386" Family: "unix"
#4. mvn --help

Lists all the maven commands.

Next post: Maven, Grails, GWT and Spring MVC.

References:

a. http://www.mkyong.com/maven/how-to-install-maven-in-ubuntu/
b. http://www.dzone.com/links/r/what_has_maven_ever_done_for_us.html


Know more about Java, Groovy, Grails artist