Maven
Maven
CLI Arguments list
Install dependency manually
1
mvn install:install-file -Dfile=./lib/ojdbc8-12.2.0.1.jar -DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
Effective POM
View all pom.xml
details by:
- IntelliJ: PPM on
pom.xml
-> Show effective POM! - or
mvn help:effective-pom
Maven settings
For standalone Maven:
${user.home}/.m2/settings.xml
${maven.home}/conf/settings.xml
For IntelliJ bundled Maven:
- Execute
mvn --version
and find Maven home location
Verify settings are properly loaded
mvn help:effective-settings
Find location of settings.xml
Add --debug
(-X
) to command.
Versioning templates
Define maven
to increase performance:
1
2
3
maven() {
mvn -T1C "$@"
}
Define release version templates:
1
2
3
4
5
# Assuming current development version is `X.Y.Z-SNAPSHOT`
RELEASE_MAJOR_TEMPLATE='${parsedVersion.nextMajorVersion}.0.0'
RELEASE_MINOR_TEMPLATE='${parsedVersion.majorVersion}.${parsedVersion.nextMinorVersion}.0'
RELEASE_PATCH_TEMPLATE='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}'
NEXT_SNAPSHOT_TEMPLATE='${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.nextIncrementalVersion}-SNAPSHOT'
Evaluate version number using given template:
1
2
3
4
5
6
7
mvn_evaluate_version() {
maven --non-recursive --quiet -DforceStdout build-helper:parse-version help:evaluate
}
evaluate_version() {
echo "$1" | mvn_evaluate_version
}
Set given version in pom.xml
files:
1
2
3
mvn_set_version() {
maven versions:set -DnewVersion="$1" -DgenerateBackupPoms=false -DprocessAllModules
}
Remove -SNAPSHOT
suffix
1
mvn versions:set -DremoveSnapshot
Batch Mode
- Use
--batch-mode
or-B
- Maven will never stop to accept input from the user. Instead, it will use sensible default values when it requires input.
- Causes Maven not to display
Progress: 125/150kB
style lines when running- Alternate way to disable it is
--no-transfer-progress
- Alternate way to disable it is
- Disables output coloring (by default maven colorizes the output)
- Will fail if prompted (e.g.
mvn versions:set
)
Optimization
-T 1C
- Use 1 Thread per Core
-Dmaven.javadoc.skip=true
-XX:-TieredCompilation -XX:TieredStopAtLevel=1
- JVM setup for short-lived processes
--offline
(-o
)- Skips looking for snapshot updates
- Tests
-DskipTests
-Dmaven.test.skip
-Dparallel=all -DperCoreThreadCount=true
- Use Maven Daemon
mvnd
- Build only specified modules
-pl $moduleName -am