2

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. components.xml source code location).

Thiago Arrais
  • 33,360
  • 7
  • 30
  • 34
Fernando Costa
  • 669
  • 1
  • 9
  • 31
  • Why are you creating a custom packaging? – khmarbaise May 01 '16 at 17:25
  • My team need to automate the build process (compile, run tests, package and deploy) of PL/SQL projects. Maven is flexible enough to be used with non Java projects too. So, we are starting to create some custom plugins and a new packaging type. – Fernando Costa May 01 '16 at 23:42

1 Answers1

4

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 goals of a plugin should be bound to which phases of that lifecycle.

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • Thanks. My misconception was based on this online book: https://books.sonatype.com/mvnref-book/reference/lifecycle-sect-package-specific.html It uses the expression "Package-specific Lifecycles", but I agree with your point. – Fernando Costa May 01 '16 at 13:54
  • 1
    @FernandoCosta This Maven book is a very good resource. Yeah the title "Package-specific Lifecycles" might a bit misleading (because it is just the default one) but the text after is correct. It is the configuration of the lifecycle that changes, not the lifecycle itself. – Tunaki May 01 '16 at 13:57
  • Why did someone capable of remove my comment of 8-10 hrs ago? It was: Re "_which plugin should be bound to which phases_" – Isn't it that _goals_ (of plugins) are bound to phases? – Gerold Broser May 02 '16 at 10:23