Krishan Chawla

Back

Maven Useful Commands

Maven commands to quickly get you going.

cli ide

๐Ÿงฉ Manually Install a Dependency (Oracle, IBM, Internal JARs)#

Used when a dependency cannot be downloaded from Maven Central due to licensing or internal policy.

Command#

mvn install:install-file \
  -Dfile=ojdbc8.jar \
  -DgroupId=com.oracle.database.jdbc \
  -DartifactId=ojdbc8 \
  -Dversion=19.3.0.0 \
  -Dpackaging=jar
bash

Use Cases#

  • Oracle JDBC drivers
  • Telecom / vendor SDKs
  • Internal utilities not published yet

๐Ÿข Deploy a Local JAR to Nexus / Artifactory#

Publish any standalone JAR to your internal Maven repository.

Command#

mvn deploy:deploy-file \
  -Durl=http://nexus.myorg.com/repository/maven-releases/ \
  -DrepositoryId=nexus \
  -Dfile=my-util.jar \
  -DgroupId=com.myorg.util \
  -DartifactId=my-util \
  -Dversion=1.0.0 \
  -Dpackaging=jar
bash

๐Ÿ” Debug Dependency Conflicts#

View full tree#

mvn dependency:tree
bash

Filter a specific dependency#

mvn dependency:tree -Dincludes=com.fasterxml.jackson.core
bash

Verbose mode#

mvn dependency:tree -Dverbose
bash

๐Ÿ”„ Force Maven to Download Latest Dependencies#

mvn clean install -U
bash

๐Ÿงฑ Build Only a Specific Module#

mvn -pl module-name -am clean install
bash

๐Ÿšซ Skip Tests (Execution or Compilation)#

Skip test execution#

mvn clean install -DskipTests
bash

Skip both compilation & execution#

mvn clean install -Dmaven.test.skip=true
bash

๐Ÿงช Run Specific Tests#

Run a single test#

mvn -Dtest=LoginTest test
bash

Run by pattern#

mvn -Dtest=User*Test test
bash

Run a specific method#

mvn -Dtest=LoginTest#shouldLoginWorks test
bash

๐Ÿงน Fix Corrupted .m2 Dependencies#

Delete a specific library#

rm -rf ~/.m2/repository/com/oracle
bash

Purge entire local repo#

mvn dependency:purge-local-repository
bash

๐Ÿ“œ Generate Effective POM#

mvn help:effective-pom
bash

๐Ÿ”ง List All Plugins Used in Build#

mvn help:effective-pom | grep plugin
bash

๐Ÿž Enable Debug Logging for CI/CD Issues#

mvn clean install -X
bash

๐Ÿ” Fix SSL Issues (PKIX Error)#

keytool -import -alias nexus \
  -file nexus.crt \
  -keystore $JAVA_HOME/jre/lib/security/cacerts
bash

๐Ÿงฉ Show Available Profiles#

List all profiles#

mvn help:all-profiles
bash

Show active profiles#

mvn help:active-profiles
bash

๐Ÿงต Build Using a Specific Profile#

mvn clean install -Pdev
bash

๐Ÿ“ฆ Download Dependencies for Offline Use#

mvn dependency:go-offline
bash

Published: 12/5/2025

Back to DevTools