You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 10 Next »

Status

This RFC is currently in the DRAFT state. Nothing in this RFC has been agreed or confirmed.

Contents

Introduction

The next generation Project Object Model to be used by Maven 5.0+

Background

Maven uses the Project Object Model as a descriptor for the declarative build requirements of a project.

  • Maven 1.x used a model which contained a <modelVersion>3.0.0</modelVersion> element as an immediate child of the root. 
  • Maven 2.x / 3.x has used a <modelVersion>4.0.0</modelVersion> element. 

Due to the way Maven has been implemented, the current release versions will consider any modelVersion other than the one that they target as invalid and will fail to parse the model.

For build time concerns, this is not that major a concern, and in fact may be desirable behaviour, e.g. I should not be able to build a Maven 2.x / 3.x project with Maven 1.x.

Where the modelVersion becomes a constraint, however, is when it comes to transitive dependency resolution. The Maven Central repository has grown in popularity, and now the consumers of the information in central are no longer only Apache Maven. There are other build tools that parse the POM to extract dependency information, e.g. Apache BuildrGradleApache Ivysbt, etc. As these build tools are not under the control of the Apache Maven project, we risk breaking their ability to parse the POM as a unit of dependency expression if we modify the pom schema or model version.

While we could change the schema if we "forked" the central repository, the experience from the previous reposotory fork (for the Maven 1.x / Model Version 3.0.0 to Maven 2.x / Model Version 4.0.0 transition) was traumatic and a repeat is generally considered to be a Bad Plan™.

The result of all this is that the Apache Maven project has been unable to evolve our POM to reflect the new needs.

The current plan for a Path Forward™ uses three legs:

  1. We keep deploying modelVersion 4.0.0 poms to the repository as a best effort expression of the dependency information of artifacts such that legacy clients can continue to consume artifacts deployed with non-legacy clients.
  2. We deploy a dependency-only model using a defined contract for forwards compatibility (to allow for future evolution) using a different file extension
  3. The POM then becomes a build-time only concern and does not need to be deployed to the repository - except for those cases where the pom may be used as either a parent or a mix-in

 

 

Overview

TODO write this up... I'm just dumping stuff I have done on the mail thread here to make it easier to collaborate:

<project modelVersion="5.0.0" [groupId="..."] artifactId="..." [version="..."] packaging="...">
  [<parent groupId="..." artifactId="..." [version="..."] [relativePath="...']/>

  [<mixin groupId="..." artifactId="..." [version="..."]/>]
  [<mixin groupId="..." artifactId="..." [version="..."]/>]
  ...
  [<mixin groupId="..." artifactId="..." [version="..."]/>]

  [<lifecycle id="..." mode="override|inherit">
    <phase id="..." [after="..." | before="..."]/>
    <phase id="..." [after="..." | before="..."]/>
    ...
    <phase id="..." [after="..." | before="..."]/>

  </lifecycle>]
  [<lifecycle id="...">
    ...
  </lifecycle>]
  ...
  [<lifecycle id="...">
    ...
  </lifecycle>]

  [<scope id="compile" [mode="override|inherit"]>
    <dependency groupId="..." artifactId="..." [platformId="..."] version="..." [classifier="..."] type="..."/> <!-- type is mandatory-->
    <dependency groupId="..." artifactId="..." [platformId="..."] version="..." [classifier="..."] type="..."/>
    ...
    <dependency groupId="..." artifactId="..." [platformId="..."] version="..." [classifier="..."] type="..."/>
  </scope>]
  [<scope id="...">
    ...
  </scope>]
  ...
  [<scope id="...">
    ...
  </scope>]

  [<plugins [mode="override|inherit"]>
    <!-- this is what pluginManagement was -->
  </plugins>]

  [<bindings [mode="override|inherit"]>
    <!-- this is what plugins was, we make explicit here that this is the binding of executions into the lifecycles -->
  </bindings>]

  [<platform id="..." [mode="override|inherit"]>
    <activation>
      <!-- define how we determine that this platform can be built in the current environment -->
    </activation>
    <!-- allow platform specific mixins -->
    [<mixin groupId="..." artifactId="..." [version="..."]/>]
    <!-- allow platform specific lifecycles -->
    [<lifecycle id="...">
      ...
    </lifecycle>]

    <!-- allow platform specific dependencies -->
    [<scope>
      ...
    </scope>]

    <!-- allow platform specific bindings... but plugin management is from the root only -->
    [<bindings>
      ...
    </bindings>]

    <!-- allow most of the other root tags except platform and packaging and deployment config -->
  </platform>]
  [<platform id="...">
    ...
  </platform>]
  ...
  [<platform id="...">
    ...
  </platform>]

  <!-- packaging is only allowed in poms with an id of "parent" or "mixin". It allows a parent/mixin to be used by different packaging ids and define specialized defaults -->
  [<packaging id="...">
    [<mixin groupId="..." artifactId="..." [version="..."]/>]
    <!-- allow platform specific lifecycles -->
    [<lifecycle id="...">
      ...
    </lifecycle>]

    <!-- allow platform specific dependencies -->
    [<scope>
      ...
    </scope>]

    <!-- allow platform specific bindings... but plugin management is from the root only -->
    [<bindings>
      ...
    </bindings>]

    <!-- allow most of the other root tags except platform and packaging and deployment config -->
  </packaging>]
  [<packaging id="...">
    ...
  </packaging>]
  ...
  [<packaging id="...">
    ...
  </packaging>]

  <!-- unsure if we still need profiles -->
  <!-- perhaps we still need properties -->
  <!-- TBD deployment config, repositories, etc -->

</project>
 

 

Some things that came to mind, in no particular order:

  • scope becomes a build time only concern. Thus we can let users define custom scopes in their pom. If we let plugin executions declare scopes to resolve, we no longer need a compiler:testCompile goal as you can just have a second default execution of compiler:compile with different required scopes and different default configuration... bonus win, I can now add many different layers of test-compilation for integration tests, etc... each pulling in different scopes... ditto for surefire/failsafe... yeah integration tests
  • we should let the user define lifecycles directly in the Pom (ok, maybe we don't *encourage it*)
  • mixins can be properly considered... they only affect build time anyway
  • Pom doesn't need to be XML any more... (maybe we want to keep XML though... just a less verbose form)
  • does Maven 5 build Maven 2/3 projects?

 

Building the effective build time model would be:

 

  • Start with parent, add in matching packaging from parent, in Pom order, add each mix-in (including matching packaging from mix-in before processing subsequent mix-ins), finally apply local pom.

 

To compute effective lifecycle and build plan, allow platform activation to be considered... each platform is like a mini-sub project that can "run in parallel" (yes I need to doc this better...)
Issues to consider: (query project = MNG AND (fixVersion = "Issues to be reviewed for 4.x" OR component = FDPFC) if you think that other issues need to be considered, just add)
  • Content to include in the POM: 
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.  (perhaps it is a legitimate concern for plugins to require parameters that have defined values from somewhere... unclear if this affects the POM though) 
    • Unable to render Jira issues macro, execution error. Open question do we want properties? and if we do, what interpolation rules would apply... how would parent, mix-in, platform, profiles etc take effect...
    • Unable to render Jira issues macro, execution error. WONT FIX I do not see the value in splitting content out of the pom... that way leads to profiles.xml which was madness
    • Unable to render Jira issues macro, execution error. WONT FIX I do not see the value in splitting content out of the pom... that way leads to profiles.xml which was madness
  • supports / provides type concepts: 
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
  • Versioning
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.  (should just do this for 5.0.0. No more plugin version "magic")
    • Unable to render Jira issues macro, execution error. WONT FIX I do not see the value in moving from the range syntax to a less mathematically complete syntax
  • Lifecycle related changes
    • Unable to render Jira issues macro, execution error.  (since the symmetry will feed into the lifecycle definition syntax perhaps)
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.  (effectively superseded as you can augment the lifecycle from within the POM and thus provide any additional phases you require in order to ensure the sequencing required)
    • Unable to render Jira issues macro, execution error.  (this one is really important as we want to be able to enable light-weight multi-module builds that just don't fail where "clean install" would succeed - solving this will mean that the reactor can proceed across all modules as required in order to deliver the requirements of the "driving" module(s))
    • Unable to render Jira issues macro, execution error.  (need to ensure that we address this need in the lifecycle declaration syntax)
  • Scope related changes
    • Unable to render Jira issues macro, execution error.  (effectively addressed above as we remove all "special" scopes replacing them with convention)
    • Unable to render Jira issues macro, execution error.
  • Better profile activation
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
    • Unable to render Jira issues macro, execution error.
  • How to format the POM
    • Unable to render Jira issues macro, execution error.  / Unable to render Jira issues macro, execution error.  (effectively addressed in the current proposal)
    • Unable to render Jira issues macro, execution error.  switching to a DSL should be considered... though I suspect a new compact XML would be less of an issue while retaining some ability to allow earlier maven versions to at least print semi-sensible errors if attempt is made to build new pom with old maven
  • Mix-ins
    • Unable to render Jira issues macro, execution error.  /  Unable to render Jira issues macro, execution error.  (should be addressed with the current proposal, but need to review what the ask in this issue was to see if any gaps exist)
    • Unable to render Jira issues macro, execution error.  (effectively addressed above)

Appendix 1 - Issues flagged for consideration post-modelVersion 4.0.0

This is not a perfect query as it includes issues that target behavioural changes outside the scope of modelVersion changes, but all the relevant issues should be a subset of this list

key summary type description status

JQL and issue key arguments for this macro require at least one Jira application link to be configured

  • No labels