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