Skip to content

Instantly share code, notes, and snippets.

@happysundar
Created February 1, 2014 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save happysundar/8747701 to your computer and use it in GitHub Desktop.
Save happysundar/8747701 to your computer and use it in GitHub Desktop.
useful maven commands

Remote debug a test started with maven

This is useful when there are a lot of libraries that are included properly during a maven package..(i.e, in any real project!)

mvn -Dmaven.surefire.debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=4044 -Xnoagent -Djava.compiler=NONE" -Dtest=GeoLocatorTest test

Display the classpath containing all dependencies and transitive dependencies

mvn dependency:build-classpath package

Show outdated dependencies

  1. To find out if plugins need an update, use : mvn versions:display-plugin-updates (and manually update the plugin version numbers in the pom)
  2. To find out if dependencies need update, use : mvn versions:display-dependency-updates
  3. To update the dependencies automatically (not recommended unless there are no API changes in the dependencies) : mvn versions:use-latest-versions goal

Thanks to Marco Morais for the list

obvious stuff

mvn compile
mvn test-compile
mvn test
mvn clean
mvn package

Download source jars when they are available

mvn dependency:sources

create a jar containing all of the dependencies

mvn assembly:assembly

generate an html report with unit test output (not too good)

mvn surefire-report:report

run a single unit test

mvn -Dtest=TestTargetingProducts test

print the contents of your pom merged with the super pom

mvn help:effective-pom

instructions for building a hadoop jar with maven

http://exported.wordpress.com/2010/01/30/building-hadoop-job-jar-with-maven/

maven plugin for hadoop

http://maven-hadoop.blogspot.com/

generate clover code coverage report

mvn clover2:instrument clover2:clover

skip tests while building the package

mvn package -DskipTests

Build a jar file containing all of the dependencies and transitive dependencies

mvn assembly:assembly -DdescriptorId=jar-with-dependencies

Prompt user for list of archetypes from which to build maven project template

mvn archetype:generate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment