Tuesday, January 14, 2014

Is it possible to make a standalone application with Maven?

Hey, I've been using Maven on web application project for most of the time, ever wonder could it be done on standalone project? The answer is yes. Make a quick search on Google, this tutorial will shows up. But that is a little bit too complicated. Can it be a little more easier? The answer is yes. (Sorry, I'm a lazy programmer.)

When launching a new Maven project, filter with maven-archetype-quickstart in the Archetype selection dialog box, pick that one and follow the instruction all the way down. A standalone project without web stuff in the project setting will be ready to accept new code.

Next question is how could I run it? This is what I have been done on my POM.xml:
  <build>
   <pluginmanagement>
    <plugins>
     <plugin>
      <groupid>org.codehaus.mojo</groupid>
      <artifactid>exec-maven-plugin</artifactid>
      <version>1.2.1</version>
     </plugin>
    </plugins>
   </pluginmanagement>
   
   <plugins>
    <plugin>
     <groupid>org.codehaus.mojo</groupid>
     <artifactid>exec-maven-plugin</artifactid>
     <version>1.2.1</version>
     <executions>
      <execution>
       <goals>
        <goal>exec</goal>
       </goals>
      </execution>
     </executions>
     <configuration>
      <mainclass>org.huahsin.Selenium2.App</mainclass>
     </configuration>
    </plugin>
   </plugins>
  </build>
In Eclipse Maven goal, put package exec:java to launch the standalone application. Take note there are some details on the exec command, read it from here.

No comments: