Maven

Maven (short for "Maven: A build tool for Java projects") is a popular build automation tool used for managing dependencies, compiling code, and packaging Java applications. Below are some commonly used Maven commands:


1. mvn clean: This command removes the target directory and all the build artifacts (compiled classes, JARs, etc.) generated from previous builds.


2. mvn compile: Compiles the source code in the `src/main/java` directory and places the compiled classes in the `target/classes` directory.


3. mvn test: Executes JUnit tests in the `src/test/java` directory. Test results are typically displayed in the console.


4. mvn package: Packages the project into a distributable format, such as a JAR, WAR, or EAR file. The packaged artifact is placed in the `target` directory.


5. mvn install: Installs the project artifact (e.g., JAR) into the local Maven repository. This allows other projects to use it as a dependency.


6. mvn deploy: Deploys the project artifact to a remote Maven repository, such as Nexus or Artifactory. This is often used in a continuous integration (CI) or continuous deployment (CD) pipeline.


7. mvn clean install: This combines the "clean" and "install" phases, cleaning the target directory and then installing the project artifact to the local repository.


8. mvn clean package: This combines the "clean" and "package" phases, cleaning the target directory and then packaging the project.


9. mvn dependency:tree: Displays a tree-like representation of the project's dependencies.


10. mvn archetype:generate: Interactive command to generate a new Maven project based on an archetype (a project template).


11. mvn compile exec:java: Compiles and runs a Java class with a main method. Useful for running standalone applications.


12. mvn help: Provides a list of Maven goals and options for the current project.


Remember to run these commands in the root directory of your Maven project, where the `pom.xml` file is located. Additionally, you can specify specific goals or phases as needed for your project's build and development process.