0

i'm wondering about how Maven maps a phase to a lifecycle.

For example when running

mvn clean

then Maven executes the phases "pre-clean" and "clean" of the "clean" lifecycle.

But how does Maven determine that the phase "clean" (as provided as command line argument) belongs to the "clean" lifecycle? There could be another lifecycle that also has a "clean" phase.

It may be a rule that all phases over all lifecycles must have a unique name. But i don't know.

Ollimaus
  • 207
  • 1
  • 6
  • AFAIK, this is the rule, yes. – Puce Jul 02 '21 at 19:58
  • In Maven there existing only the following three life cycles `clean`, `default` and `site` See https://maven.apache.org/ref/3.8.1/maven-core/lifecycles.html – khmarbaise Jul 02 '21 at 20:46
  • Yes, but there is no mentioning that phases must have unique names. One could induce that phase names are unique from studying the lifecycle reference. But at least from my point of view this would be guessing. – Ollimaus Jul 02 '21 at 20:59
  • Does this answer your question? [Maven: Relationship between Lifecycle Phase & Goal](https://stackoverflow.com/questions/8038536/maven-relationship-between-lifecycle-phase-goal) – SiKing Jul 02 '21 at 21:36

1 Answers1

0

In Maven there existing only the following three life cycles

  1. clean
  2. default
  3. site

The details are defined in the lifecycle binding of Maven core https://maven.apache.org/ref/3.8.1/maven-core/lifecycles.html

The existing and defined life cycles are defined in the following file:

META-INF/plexus/components.xml
khmarbaise
  • 92,914
  • 28
  • 189
  • 235
  • My question is not about the lifecycles, but about the phase names. If a specific phase name, such as "clean" may be defined by multiple lifecycles. If some rule forbids this, i'd be a happy camper :) – Ollimaus Jul 02 '21 at 21:19
  • The link is generated from Maven core. This means if you would ever change it the build of Maven itself will fail. And yes it will not unique anymore which would make it necessary to somehow make supplemental information given on command line ...which would a really breaking change in Maven... – khmarbaise Jul 03 '21 at 12:14
  • 1
    That answers my question. Thank you. – Ollimaus Jul 08 '21 at 18:18