« Roller Beginner's... | Main | Maven support in... »

Built with Maven

Maven Logo

I was a Maven hater and resisted it for a long time but over the years Maven has gotten much better, it's well supported in IDEs and as far as I can tell, Maven has replaced Ant as the de facto build system for Java projects. If you want new developers be able to easily build, debug and run your code via command or their favorite IDE then Maven is the way to go, and that's especially true for open source projects like Roller.

That's why I spent a couple of weekends learning Maven and converting Roller's build process from Ant to Maven (ROL-1849). The process of conversion wasn't too difficult. Getting dependencies under control was a pain, but it believe it will be a one time pain and a worthwhile one. What took the most time was figuring out how to get Maven to start Derby, create the Roller tables and then run Roller's JUnit tests. Also, getting Maven's Jetty plugin setup to run Roller was a little tricky but hopefully also a one-time pain. The result is that Roller now uses a standard and well known directory structure, dependencies are managed and it's easier for developers to get started with the codebase.

If you have Maven and Subversion installed on your computer then these commands will fetch the Roller source code, compile the code, run all JUnit tests and then build the Roller webapp:


   svn co https://svn.apache.org/repos/asf/roller/trunk roller_trunk
   cd roller_trunk 
   mvn install

And once all that is done, the following commands will start the Jetty app server, start the Derby database and start Roller at http://localhost:8080/roller, ready for testing, experimentation, etc.


   cd weblogger-web
   mvn jetty:run-war

I think that's pretty damn useful.

Here are some articles/links that influenced my thinking on Maven recently:

  • Comparing Build Systems - Adrian Sutton concludes that Maven is too much work but "the consistency in how a project is built that the Maven project has brought to the Java would is absolutely revolutionary"
  • Maven in our development process - Sherali Karimov explains how Atlassian and says the need for Maven training is "the most important and most overlooked issue of all."
  • Sonatype - The Maven Company. Founded in 2008 by Jason van Zyl, the creator of Maven. Offers training, support and the Nexus Professional repo manager.
Comments:

hey, good job ! But I'm not sure this trunk is ready for use without getting rid of some duplicated dependencies taglib.string.jar in webbloger-web and java.net repository id in the parent pom and the dependencies of maven-antrun-plugin have "test" scope. The derby tools and test-utils. It fails that it can have only [compile, runtime, system] scope. Regards, Joseph

Posted by Joseph on May 08, 2010 at 07:35 PM EDT #

[ERROR] 'build.plugins.plugin[org.apache.maven.plugins:maven-antrun-plugin].dependencies.dependency.scope' must be one of [compile, runtime, system] for org.apache.roller:test-utils:jar but is 'test'. [ERROR] 'build.plugins.plugin[org.apache.maven.plugins:maven-antrun-plugin].dependencies.dependency.scope' must be one of [compile, runtime, system] for org.apache.derby:derby:jar but is 'test'. [ERROR] 'build.plugins.plugin[org.apache.maven.plugins:maven-antrun-plugin].dependencies.dependency.scope' must be one of [compile, runtime, system] for org.apache.derby:derbynet:jar but is 'test'. [ERROR] 'build.plugins.plugin[org.apache.maven.plugins:maven-antrun-plugin].dependencies.dependency.scope' must be one of [compile, runtime, system] for org.apache.derby:derbyclient:jar but is 'test'.

Posted by Joseph on May 08, 2010 at 07:38 PM EDT #

But the migration to maven is really well done. The previous maven-antrun-plugin errors I reported happens only when Maven 3 is used. With Maven 2.x it works.

Posted by Joseph on May 08, 2010 at 07:57 PM EDT #

@Joseph: I was just surfing by and saw your comments. As I've just had the same errors on a different project, I thought I should mention (although you've probably solved it by now) that: To get it compiling with Maven 3, you need to change the scope of the dependencies inside the <plugin> <artifactId>maven-antrun-plugin</artifactId>...</plugin> from "test" to "compile". Then it should build.

Posted by Torstein Krause Johansen on November 16, 2010 at 09:28 AM EST #

I am going to do the same thing,and come across this page,thank you for your work.[That's why I spent a couple of weekends...]

Posted by Zhuxuegang on December 05, 2010 at 03:56 AM EST #

Post a Comment:
  • HTML Syntax: Allowed

« Roller Beginner's... | Main | Maven support in... »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Roller, some may be related to this entry.