Tuesday, June 2, 2020

Maven Commands

Frequently used maven commands:


mvn clean install -U -DskipTests=true

clean: clears all the compiled jars from previous previous run (compile/package/install)
-U: option fetches all jars afresh.
-DskipTests: options works only when SURE-FIRE plugin is used. (I think)


Running tests:

Run all Tests in project: 
mvn test

Run all Tests in a Test Class:
mvn test -Dtest=fully.qualified.name.of.test.class (com.myproject.business.CreateCustomerTest)

Run a Test in a Test Class
mvn test -Dtest=fully.qualified.name.of.test.class#testMethod 

Linux - Search and Copy command

Problem: 

Find all XML files that start with word TEST and copy them to a directory

Command:

find . -iname 'TEST*.java' -exec cp {} ~/path/to/directory/. \;

Gotchas:

  • make sure the command ends with \;