[ https://issues.apache.org/jira/browse/MNG-8052?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17835872#comment-17835872 ]
ASF GitHub Bot commented on MNG-8052: ------------------------------------- gnodet commented on code in PR #1411: URL: https://github.com/apache/maven/pull/1411#discussion_r1560021272 ########## api/maven-api-core/src/main/java/org/apache/maven/api/Lifecycle.java: ########## @@ -0,0 +1,157 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.maven.api; + +import java.util.*; +import java.util.stream.Stream; + +import org.apache.maven.api.annotations.Experimental; +import org.apache.maven.api.annotations.Immutable; +import org.apache.maven.api.model.Plugin; + +/** + * Lifecycle definition + * + * @since 4.0.0 + */ +@Experimental +@Immutable +public interface Lifecycle extends ExtensibleEnum { + + String CLEAN = "clean"; + + String DEFAULT = "default"; + + String SITE = "site"; + + String WRAPPER = "wrapper"; + + String PRE = "pre:"; + String POST = "post:"; + String RUN = "run:"; + + String READY = "ready"; Review Comment: It's not really used anymore in this PR, so I'll remove those new concepts and I'll defer their addition to #1429. For the record, it's used for the new lifecycle definition supporting dynamic phases and a fully concurrent build, see https://github.com/apache/maven/pull/1429/files#diff-dbccda410d9433bca88c9821a2ebd7ecb3b759738a2599a85748766c34658547R224-R252 In this PR, the phases are more fine-grained with inter-phases dependencies and more fine-grained inter-project dependencies. The lifecycle is not a simple list anymore, but looks more like a tree. So `ready` represents the state of a project which is ready to be used as a dependency. This usually means that resources have been processed and classes compiled. The main point is that the `compile` phase should not have to be executed after the `resources` phase, as they both execute on different input and output and can be executed in parallel. So `compile` phase depends on `sources` phase, and `ready` depends on `compile` and `resources`, then `package` depends on `ready`. The benefits (in addition to supporting dynamic phases with pre/post steps) is that we can have a `package` phase which does not depend on running tests, while `verify` would package and run unit/integration tests. This also cleanly solves problems coming from running `mvn compile` where some post processing can be mapped to that `ready` phase. So the definition of the tree-lifecycle above is not well defined yet, especially, the problem is how to bring those new features and keep a good level of compatibility. I'd rather have a clean set of inter-phase and inter-project dependencies (for example, `install` and `deploy` do depend on `package`, but should not depend on running unit-tests and integration-tests). Anyway, this can be deferred and discussed in the context of #1429, so I'll trim the `Lifecycle` interface to what is currently in Maven 3 (keeping in mind it can be extended in the future). > Define a new lifecycle for Maven 4 > ---------------------------------- > > Key: MNG-8052 > URL: https://issues.apache.org/jira/browse/MNG-8052 > Project: Maven > Issue Type: Improvement > Reporter: Guillaume Nodet > Priority: Major > Fix For: 4.0.x-candidate > > > The idea would be to redefine a maven lifecycle as being defined by: > {{Lifecycle}}: > * id: unique identifier > * set of Phase > {{Step}}: > * optional name > * optional mojo execution > * list of predecessors and successors for the current project > * list of predecessors and successors for dependencies > * list of predecessors and successors for child modules > Default lifecycle could be defined by a set of empty steps: > * {{initialize}} > * {{{}resources{}}}: requires {{initialize}} > * {{{}sources{}}}: requires {{initialize}} > * {{{}compile{}}}: requires {{sources}} > * {{{}ready{}}}: requires {{resources, compile}} > * {{{}build{}}}: requires {{ready}} > * {{{}test{}}}: requires {{compile}} > * {{{}package{}}}: requires {{build, test}} > * {{{}integration-test{}}}: requires {{package}} > * {{{}verify{}}}: requires {{test, integration-test}} > and a set of steps bound to plugin executions > * {{m-resources-p}} required by {{resources}} > * {{m-compiler-p}} required by {{{}compile{}}}, requires {{sources}} and > dependencies at {{ready}} > * {{m-surefire-p}} required by {{test}} > * {{m-jar-p}} required by {{build}} > * {{m-failsafe-p}} required by {{integration-test}} > The {{build}} phase would be introduced to have packaged artifacts without > running any tests. The {{ready}} phase would be introduced to allow (if > needed) a small difference between being {{{}compile{}}}'d and being > {{{}package{}}}'d: simple jars can be used as dependencies when they are only > compiled (using target/classes), but if you use a custom package (for example > {{{}m-shade-p{}}}), you cannot use the compiled classes directly, but you > need the processed classes. In such a case, the {{m-shade-p}} should be > required by {{ready}} and should require {{{}m-jar-p{}}}. > This would allow: > * injecting a given plugin into an existing chain: a custom generation step > is modelled with: {{m-generator-plugin}} required by {{sources}} > * a post packaging phase would be defined with: {{my-plugin}}: requires > {{m-jar-p}}, required by {{packaging}} > * running {{mvn build}} to build all jars without running any tests > * running {{mvn -amd test}} (or something similar) would allow building the > given project with the full graph (i.e. with all dependencies at {{ready}} > phase > * this immediately gives a full graph that can be built concurrently down to > the mojo level > * the ability to add predecessors onto children' modules phases allow > defining aggregate goals more easily -- This message was sent by Atlassian Jira (v8.20.10#820010)