Skip to main content

Maven: Command line cheatsheet

Here you find a quick reference to Maven commands.

Available commands

  • mvn -Dtest=<unqualified-classname> test: Tests only the specified class.

  • mvn -Dmaven.surefire.debug test: Enables remote debugging of tests on port 5005. Surefire blocks on the port until you connect with your debugger.

  • mvn -Dcargo.wait=true -P int integration-test: Runs CS in Tomcat via cargo.

  • mvn help:effective-pom: Shows the logical contents of a pom.xml, including contents inherited from the parent pom.xml, up to and including the Maven super POM.

  • mvn dependency:tree: Shows all dependencies (including transitive dependencies) of your project. This is very helpful for debugging dependency version issues.

  • mvn -X <package-name>: Shows all explicit and transitive dependencies for a package, helping to identify conflicts.

  • mvn dependency:sources: Downloads all project sources separate from IDE project creation. Execute from the root of the parent project, then have your IDE sync up sources.

Not currently available commands

mvn -Dupgrade.version=<version you're upgrading to> com.jivesoftware.maven:maven-upgrade-plugin:upgrade

Generates a list of diff files based on product changes that correspond to your overlays. Also generates a mirrored directory structure with product files that enables you to diff against your project's web directory.

Note: Using this command requires SVN access; a version is in development to use Maven dependencies instead.

mvn deploy:deploy-file -DgroupId=<package> -DartifactId=<artifact-name> -Dversion=<version-no> -Dpackaging=jar -Dfile=/path/to/file.jar -Durl=`https://maven.jivesoftware.com/`archiva/repository/jive.snapshots -DrepositoryId=jive.snapshots

In this example, the command deploys a jar artifact to our repository. This command working depends on your having adequate permissions.