You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Guillaume Nodet <gn...@apache.org> on 2022/04/11 10:10:27 UTC

Re: [DISCUSS] New Maven Core API for 4.x

I've raised a PR with the new immutable model at [1].  The new API would
only use the immutable model, while the old API would use the old model
rewritten to wrap the immutable model.
There are no real changes in the tests or integration tests (apart from 1
removed test), so this is really fully compatible.

[1] https://github.com/apache/maven/pull/703

Le lun. 28 mars 2022 à 11:33, Guillaume Nodet <gn...@apache.org> a écrit :

> Hi everyone,
>
> Last week, I worked on a fully immutable maven model. The results are
> available at [1].  The modifications required in modello were a bit too
> complicated, so I ended up using the modello models, but generating the
> models, readers and writers using velocity templates. The templates are
> actually way easier to modify than the modello generators, as you can see
> in the template generating the model [2] or the reader [3].  This also
> allows generating mergers and transformers.
> This also allows getting rid completely of plexus-utils dependency in the
> API.
>
> This all looks quite nice to me, however those changes are definitely
> incompatible, which means plugins will just break at runtime or compile
> time if they try to instantiate or modify objects from the model. If
> there's a consensus on trying to move forward with an immutable model, I
> can investigate generating this immutable model into a separate new package
> and only use it for the new API, and rewrite the mutable model by wrapping
> the immutable one. This would allow a smoother integration / migration.
>
> Feedback welcomed !
>
> Cheers,
> Guillaume Nodet
>
> [1] https://github.com/gnodet/maven/tree/m-api-immutable
> [2]
> https://github.com/gnodet/maven/blob/m-api-immutable/api/maven-api-model/src/main/mdo/model.vm
> [3]
> https://github.com/gnodet/maven/blob/m-api-immutable/maven-model/src/main/mdo/reader-ex.vm
>
> Le lun. 14 mars 2022 à 08:59, Guillaume Nodet <gn...@apache.org> a
> écrit :
>
>> Hi everyone,
>>
>> As Michael hinted at this new API in the "[DISCUSS] Radical Fast Forward
>> to 3.5.4" thread, I'd like to start the discussion around it.
>>
>> Over the past weeks, I've worked on an experimental API for Maven 4.x.
>> The goals are multiple :
>>   * fix some problems with designs that do not work well with
>> multithreading
>>   * offer a way to finally get rid of deprecated code
>>   * offer a complete API (which would deprecate m-artifact-transfer,
>> m-dependency-tree)
>>   * offer an homogeneous and a bit more modern API
>>   * completely hide the maven-resolver, so that it can finally upgrade to
>> a v2 with the package renamed without too much disturbance
>>
>> The goal would be to extract the models and API in a separate project
>> with a much lower release cycle, as those rarely change, but are currently
>> released with each version of maven.
>>
>> The current API can be seen at [1].  Note that the plugins API has also
>> been included within the new API and the plugin tools have been updated so
>> that the maven-plugin-plugin supports both v3 api and the new v4 api.  A
>> new flag has been added to the MojoDescriptor to know if the plugin is
>> using the old or the new api.  The plugin testing harness tools have been
>> updated to junit 5 and now provide a few annotations [2] to help writing
>> plugin tests [3].  The maven-core has been enhanced to support loading
>> those new v4 plugins along with the v3 ones, which means they can work
>> side-by-side in the same build.  This is done by implementing the new API
>> by wrapping the v3 implementation classes (such as MavenSession,
>> MavenProject, etc...) [4].
>> I've ported a few plugins such as clean [5], install [6], deploy [7] as a
>> proof-of-concept that this actually works.
>>
>> The very rough goal would be to to have multiple phases:
>>   * continue the work on this API so that it can actually cover all use
>> cases for plugins, create a new project with the new API and models, make
>> sure plugins can work correctly with the new API / implementation
>>   * release the API, then maven-core supporting the new API
>>   * upgrade plugins to the new API, deprecate old components and API
>>   * once all plugins have migrated to the new API, switch maven-core
>> implementation to the new API
>>
>> I'm eager to hear your thoughts !
>>
>> [1]
>> https://github.com/apache/maven/tree/mvn4/maven-core-api/src/main/java/org/apache/maven/api
>> [2]
>> https://github.com/apache/maven-plugin-testing/tree/mvn4/maven-plugin-testing-harness/src/main/java/org/apache/maven/api/plugin/testing
>> [3]
>> https://github.com/apache/maven-deploy-plugin/blob/mvn4/src/test/java/org/apache/maven/plugins/deploy/DeployFileMojoTest.java
>> [4]
>> https://github.com/apache/maven/tree/mvn4/maven-core/src/main/java/org/apache/maven/internal/impl
>> [5] https://github.com/apache/maven-clean-plugin/tree/mvn4/
>> [6] https://github.com/apache/maven-install-plugin/tree/mvn4/
>> [7] https://github.com/apache/maven-deploy-plugin/tree/mvn4/
>>
>> --
>> ------------------------
>> Guillaume Nodet
>>
>>
>
> --
> ------------------------
> Guillaume Nodet
>
>

-- 
------------------------
Guillaume Nodet