1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-07-28 06:55:33 +02:00
tldr/pages/common/mvn.md

37 lines
889 B
Markdown
Raw Normal View History

2017-11-29 09:35:48 +01:00
# mvn
> 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`
- 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
- 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 ...}}"`