tldr/pages/common/mvn.md

38 lines
818 B
Markdown
Raw Permalink Normal View History

2017-11-29 08:35:48 +00:00
# mvn
> Apache Maven.
> Tool for building and managing 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`
- 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
2017-12-13 06:13:18 +00:00
`mvn clean -P{{profile}} package`
2017-11-29 08:42:02 +00:00
- Run a class with a main method:
2017-11-29 08:35:48 +00:00
`mvn exec:java -Dexec.mainClass="{{com.example.Main}}" -Dexec.args="{{arg1 arg2}}"`