Send As SMS

Tuesday, February 07, 2006

Setting up code with Maven 2 and SVN

Ok, it has been a long time since my first post, but let's act like it never happened.

I decided to use Maven 2 for my code management and building. Ant was easy, but from what I had experienced, there were 841 ways to write a build script, and that always made me uneasy. Plus, I liked the bonus of what maven appeared to give: documentation perks, site creation, and library management.

Did I have any experience with Maven 1.X? No. I wasn't sure if that was a pro or a con. The docs on maven.apache.org seemed pretty good, and I did the getting started guide with relative ease.

The notion of "archtypes" really got me charged up. I was stuck at a place to start, and when you use the different create types to organize your code, I loved how it did that work for me. But how was this going to fit in with the best practices tags/, trunk/ branches/ directory structure of subversion? Time to put two directory layout conventions together like chocolate and peanut butter.

For my project, I was developing two APIs and two webapps - the APIs would be packaged as jars and the webapps would be packaged as WARs. Therefore, I decided to do create four specific code projects.

Couple this with SVN!! Oy, now how do I integrate one into the other. I decided to combine both and do this:

app1-core
/trunk
/tags
/branches

app2-webapp
/trunk
/tags
/branches

app2-core
/trunk
/tags
/branches

app2-webapp
/trunk
/tags
/branches

Now, within trunk is where the maven part starts. So within each trunk/ directory, there is another named directory after the trunk, so each project goes like this:

app1-core/trunk/app1-core
app1-core/trunk/app1-webapp
app2-core/trunk/app2-core
app2-webapp/trunk/app2-webapp

each of these directories contains the main src/ and pom.xml pieces for Maven. Was it overkill? I don't think so. Was it a lot of switching around of directories? At first, yes, but that is why we have bash profile and windows properties for setup aliases. 99% of the time I was bouncing around to each project home so doing "cd $app1core" was a lot easier than doing "cd ~/app1-core/trunk/app1-core".

So when I was done I was happy. I felt like my project setup was like the 2-person horse costume. The high level directories were the horse's rear for subversion - project names followed by the trunk/, tags/ branches/ convention. And the horse's front part (wink, where the brains are) are the project directories for maven.

More catching up to do. The next entry will be on the fine balance of the pros and cons of maven 2.

0 Comments:

Post a Comment

<< Home