Skip to end of metadata
Go to start of metadata

Custom profile activators allow you to write your own implementation of <tt>org.apache.maven.profiles.activation.ProfileActivator</tt>, import it into a project as a build extension, and use it to activate profiles in your build.


We can declare the profile that uses our new custom activator in the parent POM, along with the extension containing its implementation:

Then, to activate the <tt>versionless-archive</tt> profile in our child POM, we add the specified POM property, like this:

This makes it a simple task to customize your projects by using profiles as mix-ins. These profiles can be maintained at a single point, in the parent POM.

Finally, the custom profile activator might look like this:


  1. The Java source code above relies on the new Build Context feature of Maven 2.1. This feature allows components in the Maven runtime - including mojos - to import and export shared, structured information. It's important to note that this feature is not yet completely stabilized; therefore, the code above will be changing in the future, in response to changes in the Build Context.
  • No labels

1 Comment

  1. Warning - Before you try this at home:

    The Build Context feature has not made it into Maven 2.1.0. Still worse - as far as I can see, it has been removed from the 2.1 and 2.2 branches as well.

    Thus I suspect this feature either has been discontinued altogether or been pushed forward to Maven 3. There is a source branch at that - in my opinion - only serves archival purposes.