Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8052] New lifecycle for Maven 4 #1448

Merged
merged 2 commits into from
Aug 29, 2024
Merged

Conversation

gnodet
Copy link
Contributor

@gnodet gnodet commented Mar 21, 2024

JIRA issue: MNG-8052

The lifecycle is now defined as a tree of phases, each phase being split with a before: phase and a after: phase. Each phase is given a list of timing constraints: a phase from the same lifecycle (compile must be executed after sources), a phase in project dependencies (compile must execute after compile-only project dependencies have reached the ready phase), or a set of children project dependencies (to re-define aggregators, not yet implemented).
The default lifecycle is defined in the DefaultLifecycleRegistry

In addition to the before: and after: prefixes, an ordering can be defined by appending an integer inside brackets, for example, after:integration-test[1000].

Note that there are a few changes with the Maven 3 default lifecycle: it's a graph, so sources does not always execute after resources, nor compile after resources. Also, unit tests and integration tests have been moved to the verify phase which is run last inside the build phase, but not in the package phase. The goal is to have a phase (here, package which can run all the reactor with no tests). In order to be compatible, old phases are mapped to new ones using aliases. The install and deploy phases now depends on package, but not verify (and deploy does not require install). This currently has no effect when calling mvn deploy, as the ordered list of phases is still used to compute the build plan (see #1429).

It's missing the ability to create some scheduling constraints in the POM and to define custom phases. All executions in a given phase such as compile or after:sources are executed sequentially, but it would be nice to be able to execute them in different subphases, so that they could be executed concurrently.

This PR is required for #1429

@gnodet gnodet force-pushed the dynamic-phases branch 3 times, most recently from 528b744 to 70e4122 Compare June 12, 2024 13:08
@gnodet gnodet changed the title [MNG-5668] Proof of concept implementation of dynamic phases (wip) [MNG-5668] Dynamic phases (wip) Jun 12, 2024
@gnodet gnodet changed the title [MNG-5668] Dynamic phases (wip) [MNG-5668] Dynamic phases Jun 12, 2024
@gnodet gnodet added this to the 4.0.0-beta-4 milestone Jul 9, 2024
@gnodet gnodet marked this pull request as ready for review July 10, 2024 12:01
@gnodet gnodet changed the title [MNG-5668] Dynamic phases [MNG-8052] New lifecycle for Maven 4 Aug 28, 2024
@gnodet gnodet force-pushed the dynamic-phases branch 2 times, most recently from 705fd88 to 1446474 Compare August 28, 2024 08:57
@gnodet gnodet merged commit acec540 into apache:master Aug 29, 2024
13 checks passed
@oehme
Copy link
Contributor

oehme commented Oct 7, 2024

@gnodet One of our tests broke after this change made it into the nightlies - We test a custom lifecycle like

<role>org.apache.maven.lifecycle.Lifecycle</role>
<role-hint>custom_hint</role-hint>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<configuration>
  <id>custom_lifecycle</id>
  <phases>
    <phase>phase1</phase>
    <phase>phase2</phase>
    <phase>phase3</phase>
  </phases>
...

Before this change, the phases were executed in the correct order, i.e. calling phase3 would first run phase1 and phase2. After this change, the order is now reversed.

Looking through the Maven integration tests, there doesn't seem to be a test case for custom lifecycles. And since maven-core no longer uses components.xml itself, this went undiscovered.

@gnodet
Copy link
Contributor Author

gnodet commented Oct 7, 2024

@gnodet One of our tests broke after this change made it into the nightlies - We test a custom lifecycle like

<role>org.apache.maven.lifecycle.Lifecycle</role>
<role-hint>custom_hint</role-hint>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<configuration>
  <id>custom_lifecycle</id>
  <phases>
    <phase>phase1</phase>
    <phase>phase2</phase>
    <phase>phase3</phase>
  </phases>
...

Before this change, the phases were executed in the correct order, i.e. calling phase3 would first run phase1 and phase2. After this change, the order is now reversed.

Looking through the Maven integration tests, there doesn't seem to be a test case for custom lifecycles. And since maven-core no longer uses components.xml itself, this went undiscovered.

Could you raise a JIRA issue and provide a small project to reproduce the problem ?

@oehme
Copy link
Contributor

oehme commented Oct 10, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants