Fernando Costa Fernando Costa - 5 months ago 12x
Java Question

Where is Maven lifecycle defines for the JAR packaging?

I'm creating a custom Maven packaging based on the lifecycle of the JAR packaging. I'd like to known where this lifecycle is defined (i.e.

source code location).


You have a small misconception in your question. The "jar" packaging doesn't have a special lifecycle. It is based on the default lifecycle.

From the lifecycle reference:

Maven defines 3 lifecycles in META-INF/plexus/components.xml:

  • default Lifecycle
  • clean Lifecycle
  • site Lifecycle

You can find this components.xml file in the source code here for Maven 3.3.9. The default lifecycle does not define any bindings since they depend on the packaging:

default lifecycle is defined without any associated plugin. Plugin bindings for this lifecycle are defined separately for every packaging.

Each of the standard packaging (like "jar") defines plugins that are bound to specific phases of this default lifecycle. You can find those bindings inside the file default-bindings.xml.

The goal of having those two separate files is to make a distinction between the lifecycle, which defines what phases it includes, and the packaging, which defines which plugin should be bound to which phases of that lifecycle.