Faster testing with the Maven CLI plugin

Although it’s not that new, I discovered Don Brown’s Maven CLI plugin only this morning, and played with mojavelinux‘ s enhanced version which supports -D parameters and profiles, among other things.

The great thing is to be able to run a simple test or test -D MyTest command quickly. You first start Maven with mvn cli:execute-phase, which gives you a maven2> command prompt to start Maven lifecycle phases. As Maven is already started, phases run much quicker than when starting from scratch.

In my experiments, the test command ran about five times faster than using mvn -o test, but the difference depends how fast your tests are, of course.

To setup the plugin, I’m adding the following to my settings.xml, so as to not interfere with project’s POMs, as the CLI is more an environment feature than a project thing:

<!-- 
  mvn settings.xml that enable the CLI plugin described at

http://tinyurl.com/maven-cli-plugin

  (For example "mvn cli:execute-phase")
-->
<settings>
  <pluginGroups>
    <pluginGroup>org.twdata.maven</pluginGroup>
  </pluginGroups>
  <profiles>
    <profile>
      <id>cli-plugin</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <pluginRepositories>
        <pluginRepository>
          <id>repository.jboss.org</id>
          <name>JBoss Repository</name>
          <url>http://repository.jboss.org/maven2</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

Find more info on the mojavelinux page.

Great tool – thanks Don Brown and mojavelinux!

2 Responses to Faster testing with the Maven CLI plugin

  1. The standard cli goal is “cli:execute”, which works in more cases (the execute-phase goal did not work with more complex poms).

  2. David says:

    I completely agree with the ahutor of this article. Using maven with eclipse is driving me crazy. Especially when it comes to creating a simple J2EE app with one EAR, WAR, EJB and Util project. The wtp support is damn poor. Even after maven eclipse plugin is run with the wtp option, the project does not appear to be a EJB or dynamic web project. I had to manually tweak the pom to add all the stupid nature and facets (jst.ejb, jst.web) etc. I like eclipse very much.. just a few clicks and within seconds the project structure is neatly created. Of course I agree with Maven’s philosophy and would love to use it.. But lack of proper support in eclipse is just @#$%. I tried m2eclipse and the maven eclipse from apache.. both sucks If eclipse fails to recognize the project as EJB or web project the option of using wizards just disappear.. and i have to manually identify each and every jar and add it. Then eclipse becomes comparable to a text editor sans colour and views !!. With Maven gaining lot of popularity, its better that the folks at eclipse take the integration more serious. I heard that Netbeans is having a great support to Maven.. So I am off to using Netbeans.. One eclipse fan minus

Follow

Get every new post delivered to your Inbox.

Join 31 other followers

%d bloggers like this: