2025-03-14 21:59:59 -06:00
|
|
|
# mvn
|
|
|
|
|
|
|
|
|
|
> Apache Maven: build and manage Java-based projects.
|
2025-05-08 12:26:01 -06:00
|
|
|
> More information: <https://manned.org/mvn>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Compile a project:
|
|
|
|
|
|
|
|
|
|
`mvn compile`
|
|
|
|
|
|
|
|
|
|
- Compile and package the compiled code in its distributable format, such as a `jar`:
|
|
|
|
|
|
|
|
|
|
`mvn package`
|
|
|
|
|
|
|
|
|
|
- Compile and package, skipping unit tests:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`mvn package {{[-D|--define]}} skipTests`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Install the built package in local maven repository. (This will invoke the compile and package commands too):
|
|
|
|
|
|
|
|
|
|
`mvn install`
|
|
|
|
|
|
|
|
|
|
- Delete build artifacts from the target directory:
|
|
|
|
|
|
|
|
|
|
`mvn clean`
|
|
|
|
|
|
|
|
|
|
- Do a clean and then invoke the package phase:
|
|
|
|
|
|
|
|
|
|
`mvn clean package`
|
|
|
|
|
|
|
|
|
|
- Clean and then package the code with a given build profile:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`mvn clean {{[-P|--activate-profiles]}} {{profile}} package`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Run a class with a main method:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`mvn exec:java {{[-D|--define]}} exec.mainClass="{{com.example.Main}}" {{[-D|--define]}} exec.args="{{argument1 argument2 ...}}"`
|