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-8214] Improve model velocity template to support subclasses #1660

Merged
merged 3 commits into from
Aug 27, 2024

Conversation

kwin
Copy link
Member

@kwin kwin commented Aug 16, 2024

This makes the constructor protected and takes the Builder as argument

Following this checklist to help us incorporate your
contribution quickly and easily:

  • Make sure there is a JIRA issue filed
    for the change (usually before you start working on it). Trivial changes like typos do not
    require a JIRA issue. Your pull request should address just this issue, without
    pulling in other changes.
  • Each commit in the pull request should have a meaningful subject line and body.
  • Format the pull request title like [MNG-XXX] SUMMARY,
    where you replace MNG-XXX and SUMMARY with the appropriate JIRA issue.
  • Also format the first line of the commit message like [MNG-XXX] SUMMARY.
    Best practice is to use the JIRA issue title in both the pull request title and in the first line of the commit message.
  • Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
  • Run mvn clean verify to make sure basic checks pass. A more thorough check will
    be performed on your pull request automatically.
  • You have run the Core IT successfully.

If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.

To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.

@kwin kwin requested a review from gnodet August 16, 2024 16:15
@gnodet
Copy link
Contributor

gnodet commented Aug 16, 2024

I don't really see what's your use case for that ? We already have inheritance such as Build extends BuildBase and it works correctly. Is that just a cleanup ?

@kwin
Copy link
Member Author

kwin commented Aug 17, 2024

This is not about inheritance within MDO models but inheritance of classes generated from MDO, like for https://github.com/apache/maven-plugin-tools/blob/9332b09acc08d2e063f12a8158a57ca8ec56fadd/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/ExtendedMojoDescriptor.java#L31. This is currently not possible due to the restricted visibility of the constructors and the lack of a constructor taking a builder as argument.

src/mdo/model.vm Outdated Show resolved Hide resolved
@gnodet
Copy link
Contributor

gnodet commented Aug 17, 2024

This is not about inheritance within MDO models but inheritance of classes generated from MDO, like for https://github.com/apache/maven-plugin-tools/blob/9332b09acc08d2e063f12a8158a57ca8ec56fadd/maven-plugin-tools-api/src/main/java/org/apache/maven/tools/plugin/ExtendedMojoDescriptor.java#L31. This is currently not possible due to the restricted visibility of the constructors and the lack of a constructor taking a builder as argument.

Fair point. However the use case of ExtendedMojoDescriptor is definitely a bad one. Those were needed because the models did not really evolved, but we allowed small additions without properly versioning them, and then rely on such hacks.

@kwin kwin force-pushed the feature/MNG-8214-improved-builder-in-velocity branch from d62176b to 93079ea Compare August 17, 2024 12:50
@kwin
Copy link
Member Author

kwin commented Aug 17, 2024

However the use case of ExtendedMojoDescriptor is definitely a bad one.

I only partially agree, extending the MDO for this case is not useful as the additional attribute really only is useful in the plugin-tools context and therefore this class is only used internally. Although one could probably do things differently, the effort when not extending the original Maven classes is considerably higher (as one somehow needs to establish the connection between the raw Maven object and the extended plugin tools one).

@kwin kwin force-pushed the feature/MNG-8214-improved-builder-in-velocity branch from 93079ea to c994b63 Compare August 17, 2024 14:42
src/mdo/model.vm Outdated Show resolved Hide resolved
src/mdo/model.vm Outdated Show resolved Hide resolved
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The $additionalArguments needs to be removed

@kwin kwin force-pushed the feature/MNG-8214-improved-builder-in-velocity branch 4 times, most recently from ae77de5 to a0bde50 Compare August 18, 2024 10:23
Make the constructors protected and take the Builder as argument
@kwin kwin force-pushed the feature/MNG-8214-improved-builder-in-velocity branch from a0bde50 to 402c8c2 Compare August 18, 2024 10:35
@kwin kwin marked this pull request as ready for review August 18, 2024 10:36
@kwin kwin requested a review from gnodet August 18, 2024 10:36
Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The locations field should be immutable.

src/mdo/model.vm Outdated Show resolved Hide resolved
@kwin kwin force-pushed the feature/MNG-8214-improved-builder-in-velocity branch from 8bc5d20 to 8ce4cde Compare August 26, 2024 15:07
src/mdo/model.vm Outdated Show resolved Hide resolved
@kwin kwin merged commit 7306c41 into master Aug 27, 2024
14 of 25 checks passed
@kwin kwin deleted the feature/MNG-8214-improved-builder-in-velocity branch August 27, 2024 07:05
This pull request was closed.
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.

2 participants