DevTools
Apache Maven CLI
Apache Maven commands for Java project management.
31 commands
Windows
MacOS
Linux
#java
#build-tool
Project Lifecycle
Remove the target directory
mvn clean
Compile the source code
mvn compile
Run unit tests
mvn test
Build the project and create JAR/WAR
mvn package
Install the artifact to local repository
mvn install
Deploy artifact to remote repository
mvn deploy
Run integration tests and checks
mvn verify
Build and install, skipping tests
mvn clean install -DskipTests
Dependency Management
Display the dependency tree
mvn dependency:tree
Resolve all project dependencies
mvn dependency:resolve
Analyze used and unused dependencies
mvn dependency:analyze
Remove deps from local repo and re-resolve
mvn dependency:purge-local-repository
Show available dependency updates
mvn versions:display-dependency-updates
Show available plugin updates
mvn versions:display-plugin-updates
Plugin Execution
Generate a project from an archetype
mvn archetype:generate
Run a Java main class
mvn exec:java -Dexec.mainClass=com.example.Main
Generate Javadoc documentation
mvn javadoc:javadoc
Generate the project site
mvn site
Generate test report
mvn surefire-report:report
Profiles
Activate a specific build profile
mvn clean install -P production
Show currently active profiles
mvn help:active-profiles
List all available profiles
mvn help:all-profiles
Deactivate a specific profile
mvn clean install -P !development
Multi-Module
Build only a specific module
mvn clean install -pl module-api
Build a module and its dependencies
mvn clean install -pl module-api -am
Build a module and its dependents
mvn clean install -pl module-api -amd
Resume build from a specific module
mvn clean install -rf :module-web
Build with 4 threads for parallelism
mvn clean install -T 4
Quick Commands
Clean the project, compile, test, package, and install to local repository
mvn clean install
Display the full dependency tree of the project
mvn dependency:tree
Build the project with a specific Maven profile activated
mvn clean install -P production