Author: Dalbert Onyebuchi
This project is licensed under the MIT License - see the LICENSE file for details.
https://www.digitalocean.com/community/tutorials/maven-commands-options-cheat-sheet
# The Maven Clean Plugin, as the name implies, attempts to clean the files and directories generated by Maven during its build.
# While there are plugins that generate additional files, the Clean Plugin assumes that these files are generated inside the target directory.
mvn clean
mvn clean package
The `mvn build` command is commonly used in Apache Maven, a popular build automation and dependency management tool for Java projects.
When you run `mvn build`, it triggers the default build lifecycle of Maven, which consists of a series of phases and goals.
During the build process, Maven reads the project's configuration file (`pom.xml`) and performs various tasks such as compiling source code,
running tests, packaging the application, and managing dependencies.
These tasks are organized into different phases, such as `compile`, `test`, `package`, `install`, and `deploy`, among others.
The `mvn build` command typically executes all the phases in the default lifecycle up to the `package` phase.
This means that Maven compiles the source code, runs unit tests, and packages the application into a distributable format (such as a JAR or WAR file).
However, it does not install or deploy the packaged artifact.
By default, Maven uses the `pom.xml` file in the current directory to determine the project's configuration and dependencies.
It relies on convention over configuration, meaning that it follows a predefined project structure and naming conventions to simplify the build process.
It's important to note that `mvn build` is not the exact syntax of the command.
The correct Maven command is `mvn clean package` to clean the previous build artifacts and then execute the build process up to the `package` phase.
mvn compile
mvn test
# Run all the unit test classes.
$ mvn test
# Run a single test class.
$ mvn -Dtest=TestApp1 test
# Run multiple test classes.
$ mvn -Dtest=TestApp1,TestApp2 test
# Run a single test method from a test class.
$ mvn -Dtest=TestApp1#methodname test
# Run all test methods that match pattern 'testHello*' from a test class.
$ mvn -Dtest=TestApp1#testHello* test
# Run all test methods match pattern 'testHello*' and 'testMagic*' from a test class.
$ mvn -Dtest=TestApp1#testHello*+testMagic* test