2017-11-29 08:35:48 +00:00
|
|
|
# mvn
|
|
|
|
|
2017-12-12 14:21:07 +00:00
|
|
|
> Apache Maven.
|
|
|
|
> Tool for building and managing Java-based projects.
|
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:
|
|
|
|
|
|
|
|
`mvn package -Dmaven.test.skip=true`
|
|
|
|
|
|
|
|
- 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
|
|
|
|
2017-12-13 06:13:18 +00: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
|
|
|
|
2017-12-12 14:21:07 +00:00
|
|
|
`mvn exec:java -Dexec.mainClass="{{com.example.Main}}" -Dexec.args="{{arg1 arg2}}"`
|