Skip to content
Latchkey

mvn -P: Activate Build Profiles

mvn -P<id> activates one or more named profiles, switching plugin config, properties, and dependencies for environments like ci or release.

Profiles let one pom behave differently per environment. -P explicitly turns them on, which is more predictable in CI than relying on auto-activation.

What it does

The -P flag takes a comma-separated list of profile ids to activate, defined in pom.xml, an active profile in settings.xml, or a profiles file. Prefixing an id with ! (or -) deactivates it. Activated profiles can add dependencies, set properties, and reconfigure plugins.

Common usage

Terminal
mvn -B package -Pci
mvn -B deploy -Prelease,ossrh
# deactivate a profile that is otherwise auto-active
mvn -B package -P'!integration'

Flags

FlagWhat it does
-P<id>[,<id>...]Activate the listed profiles
-P!<id>Deactivate a profile
help:active-profiles (goal)Print which profiles are active
-BBatch mode for CI

In CI

Activate a dedicated ci profile with -Pci rather than depending on OS/JDK auto-activation, which differs between your laptop and the runner. To debug "wrong profile active", run mvn help:active-profiles. Cache ~/.m2 as usual.

Common errors in CI

"The requested profile 'X' could not be activated because it does not exist." means the id is misspelled or defined elsewhere (e.g. only in your local settings.xml, not on the runner). A profile that silently does nothing in CI is often gated by an <activation> condition (JDK/OS) that the runner does not meet; activate it explicitly with -P.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →