Wednesday, February 16, 2011

Most wanted Maven commands

... which I used to forget!

  • Build project quickly: don't check if there are updated artifacts (i.e., offline mode) and don't run tests
    cd [project root dir]
    mvn clean install -o -DskipTests
  • Run main() method of your java class
    mvn exec:java -Dexec.mainClass="com.example.Main" [-Dexec.args="argument1"]
  • Build a project module and all modules it depends on
    cd [project root dir]
    mvn clean install -pl [relative path from current dir to module you want to build] -am
  • Continue to build a project from the module on which previous build procedure has been interrupted (for example, because of build failure)
    cd [project root dir]
    mvn clean install -rf [relative path from current dir to module on which previous build procedure has been interrupted]
  • Get the project dependency tree
    mvn dependency:tree
  • Run specific goal for a given plugin
    mvn [plugin groupId]:[plugin artifactId]:[specific goal]
  • Initialize new project in maven way
    mvn archetype:generate
  • Generate Eclipse project file(s) for your (built with Maven) project
    cd [project root dir]
    mvn eclipse:clean eclipse:eclipse

0 comments:

Post a Comment