What this animation explains
Profiles merge build configuration when active. They are not Java runtime profiles; the example uses a property to represent an environment.

MODULE 2 · TOPIC 7 · VISUAL MAVEN LAB
Maven profiles customize the effective build model for particular environments or build conditions. They can change properties, dependencies, plugins and resource configuration when activated. Profiles are build-time mechanisms, not automatic runtime switches. The experiments show how activation, merging and filtering change the build and how runtime settings remain independent.
Browser-based Maven simulations: change the inputs and trace commands, POM configuration and build results. No real Maven commands, downloads or file changes are executed.
A profile is a named set of conditional POM configuration. When active, it contributes its settings to the effective build model. Profiles can represent development, testing or production build needs without maintaining separate copies of the entire POM.
Why this example? Select dev, test or prod and inspect the resulting property. This shows how the same project can produce different build configurations while keeping a common project definition.
Arrows show the actual route; blue identifies the current node. Green indicates visited operations; red nodes show errors or rejected paths.
Change the input and step through the example. Commands and XML fragments are illustrative; use the real Maven installation and the specified project files to reproduce them.
Profiles merge build configuration when active. They are not Java runtime profiles; the example uses a property to represent an environment.
Change dev to prod and inspect the merged property.
Profiles can activate explicitly through -P or implicitly through conditions such as user properties. An activeByDefault profile in a POM is suppressed when another profile in that same POM becomes active. More than one profile may be active at a time.
Why this example? Compare explicit, property and default activation scenarios. Observe the selected profile set to understand why a default configuration can disappear without manually disabling it.
Arrows show the actual route; blue identifies the current node. Green indicates visited operations; red nodes show errors or rejected paths.
Change the input and step through the example. Commands and XML fragments are illustrative; use the real Maven installation and the specified project files to reproduce them.
A default-active profile in a POM is deactivated when another profile from that POM becomes active. Property activation depends on the specified property. Multiple explicit profiles may be active.
Compare Default only with Another profile active.
Resource filtering replaces placeholders in configured text resources with effective Maven property values during the build. The selected profile can supply those values. Filtering is optional, and credentials should not be embedded in packaged resources.
Why this example? Choose a profile and follow the placeholder to the generated app.properties content. This demonstrates how profile configuration affects an actual file in the build output rather than just a label in the POM.
Arrows show the actual route; blue identifies the current node. Green indicates visited operations; red nodes show errors or rejected paths.
Change the input and step through the example. Commands and XML fragments are illustrative; use the real Maven installation and the specified project files to reproduce them.
Resource filtering substitutes configured Maven properties into text resources. Enable filtering explicitly and avoid filtering binary files. Never embed production credentials in a packaged resource.
Switch profile and observe the generated app.properties.
Explicit activation and property-based activation can occur together. Profiles are not mutually exclusive by default, so Maven can merge contributions from multiple active profiles. Default activation has a special suppression rule within the same POM.
Why this example? Toggle explicit QA activation and env=prod independently. Inspect the active set, including both QA and prod together, to understand why specifying one profile does not necessarily disable every other profile.
Arrows show the actual route; blue identifies the current node. Green indicates visited operations; red nodes show errors or rejected paths.
Change the input and step through the example. Commands and XML fragments are illustrative; use the real Maven installation and the specified project files to reproduce them.
Profiles are not exclusive by default. Explicit and implicit activations can combine; an activeByDefault profile in the same POM is suppressed when another activates.
Choose Explicit QA plus env=prod to see both profiles active, then remove both to restore dev.
When multiple active profiles in one POM define the same scalar property, the later declaration can override the earlier one. This is distinct from the order in which profile names appear on the command line. Other model elements can have more complex merge rules.
Why this example? Activate both dev and prod, reverse their declaration order and compare the effective app.env. Then select only one profile to see how avoiding overlapping definitions removes the ambiguity.
Arrows show the actual route; blue identifies the current node. Green indicates visited operations; red nodes show errors or rejected paths.
Change the input and step through the example. Commands and XML fragments are illustrative; use the real Maven installation and the specified project files to reproduce them.
If active profiles in the same POM define the same scalar property, the later-declared profile takes precedence. This is distinct from CLI activation order.
Activate both, reverse the declaration order, and inspect app.env. Use one profile only to eliminate the conflict.
Build-time settings are resolved while Maven produces an artifact. Runtime settings are read by the application when it runs, if the application is written or configured to do so. A Maven profile does not automatically set a running Java application’s environment.
Why this example? Build with dev or prod and independently choose a runtime APP_ENV override. Follow the packaged default and the runtime value to understand how one artifact can support different deployment environments.
Arrows show the actual route; blue identifies the current node. Green indicates visited operations; red nodes show errors or rejected paths.
Change the input and step through the example. Commands and XML fragments are illustrative; use the real Maven installation and the specified project files to reproduce them.
Maven profiles affect build configuration. Runtime environment variables affect application behavior only if the application reads them.
Build with dev, set runtime prod, and inspect which value is used. Remove the override to fall back to the packaged default.
Use these commands in the terminal of a real Maven project. Each serves a different purpose; the simulations above show the corresponding logic.
| Command | Why and when to use it |
|---|---|
| mvn help:active-profiles | See active profiles |
| mvn -Pdev help:effective-pom | Inspect effective model for dev |
| mvn -Denv=prod help:active-profiles | Activate property-based profile if configured |
| mvn -Pdev process-resources | Process configured filtered resources |
| mvn -Pprod clean verify | Build with prod configuration |
| mvn -Pdev,prod help:effective-pom | Inspect overlapping profile contributions |
Follow the steps in order using a real JDK and Maven installation. XML snippets marked as fragments belong inside the relevant POM element.
<profiles> <profile><id>dev</id><activation><activeByDefault>true</activeByDefault></activation><properties><app.env>dev</app.env></properties></profile> <profile><id>prod</id><properties><app.env>prod</app.env></properties></profile> </profiles> <!-- Add inside existing build element: --> <resources><resource><directory>src/main/resources</directory><filtering>true</filtering></resource></resources>
mvn -Pdev,prod help:active-profiles mvn -Pdev,prod help:effective-pom
Try answering these questions, then expand each answer and repeat the appropriate simulation.
No. Maven profiles configure a build; runtime behavior depends on the application and its configuration.
The default-active profile is suppressed.
No. Use runtime secrets/configuration, not packaged credentials.
Create dev and prod profiles with different non-secret properties. Run mvn -Pdev help:active-profiles and mvn -Pprod help:effective-pom, then compare filtered resources.
Edit the scratchpad below. Copy the appropriate command or XML fragment into your real Maven project to test it.
Profiles are build-time configuration. Use runtime environment variables or secret management for sensitive values. The simulated URLs use illustrative endpoints.