2017-11-29 09:35:48 +01:00
|
|
|
# mvn
|
|
|
|
|
2024-02-14 17:25:13 -03:00
|
|
|
> Apache Maven: build and manage Java-based projects.
|
2025-05-04 20:03:26 +03:00
|
|
|
> More information: <https://manned.org/mvn>.
|
2017-11-29 09:35:48 +01:00
|
|
|
|
2017-12-13 11:43:18 +05:30
|
|
|
- Compile a project:
|
|
|
|
|
|
|
|
`mvn compile`
|
|
|
|
|
|
|
|
- Compile and package the compiled code in its distributable format, such as a `jar`:
|
2017-11-29 09:35:48 +01:00
|
|
|
|
|
|
|
`mvn package`
|
|
|
|
|
2017-12-13 11:43:18 +05:30
|
|
|
- Compile and package, skipping unit tests:
|
|
|
|
|
2025-05-04 20:03:26 +03:00
|
|
|
`mvn package {{[-D|--define]}} skipTests`
|
2017-12-13 11:43:18 +05:30
|
|
|
|
|
|
|
- Install the built package in local maven repository. (This will invoke the compile and package commands too):
|
|
|
|
|
|
|
|
`mvn install`
|
|
|
|
|
2019-02-11 19:00:49 +01:00
|
|
|
- Delete build artifacts from the target directory:
|
2017-11-29 09:35:48 +01:00
|
|
|
|
2017-12-13 11:43:18 +05:30
|
|
|
`mvn clean`
|
2017-11-29 09:35:48 +01:00
|
|
|
|
2017-12-13 11:43:18 +05:30
|
|
|
- Do a clean and then invoke the package phase:
|
2017-11-29 09:42:02 +01:00
|
|
|
|
2017-12-13 11:43:18 +05:30
|
|
|
`mvn clean package`
|
2017-11-29 09:42:02 +01:00
|
|
|
|
2017-12-13 11:43:18 +05:30
|
|
|
- Clean and then package the code with a given build profile:
|
2017-11-29 09:42:02 +01:00
|
|
|
|
2025-05-04 20:03:26 +03:00
|
|
|
`mvn clean {{[-P|--activate-profiles]}} {{profile}} package`
|
2017-11-29 09:42:02 +01:00
|
|
|
|
2017-12-12 15:21:07 +01:00
|
|
|
- Run a class with a main method:
|
2017-11-29 09:35:48 +01:00
|
|
|
|
2025-05-04 20:03:26 +03:00
|
|
|
`mvn exec:java {{[-D|--define]}} exec.mainClass="{{com.example.Main}}" {{[-D|--define]}} exec.args="{{argument1 argument2 ...}}"`
|