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-8331] Sometimes versioned dependencies disappear #1821

Merged
merged 3 commits into from
Oct 19, 2024

Conversation

jjkester
Copy link
Contributor

@jjkester jjkester commented Oct 19, 2024

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.

Ensure all dependencies end up in the model
@mthmulders
Copy link
Contributor

Corresponding IT: apache/maven-integration-testing#393.

@cstamas
Copy link
Member

cstamas commented Oct 19, 2024

There is a more trivial PR #1822 which avoids model modification if unneeded.

@cstamas
Copy link
Member

cstamas commented Oct 19, 2024

Another alternative mixing the two solutions: #1823

@cstamas
Copy link
Member

cstamas commented Oct 19, 2024

@jjkester could you please add the "empty check" to the beginning of the method (so avoid any work and allocation if there is nothing to be done)? like in #1823

@jjkester
Copy link
Contributor Author

jjkester commented Oct 19, 2024

@cstamas, I did not add one because in practice I do not expect many projects to have zero dependencies. If a project does have zero dependencies, the only "waste" is the allocation of an unnecessary ArrayList of size 0, and unnecessarily creating a new Model instance with that list. Personally I don't think that optimalization (given the assumed rarity) is worth the additional complexity in the method, which is already quite complex.

If my assumption and/or preference is not in line with the general way in which Maven is coded, I'm happy to add the optimalization, but I'd like to check the necessity first.

@cstamas
Copy link
Member

cstamas commented Oct 19, 2024

For example, all the parents, aggregators, BOMs etc will not have any of those. This is about all the "subprojects" within a project (just to clarify "I do not expect project with zero dependencies" -- they may still have subprojects with zero deps even if project as a whole does have deps) and while I cannot tell the usual ratio of things like parent vs non-parent POMs in a project, they are there.

Just my 5cts

@cstamas
Copy link
Member

cstamas commented Oct 19, 2024

Ugh, reformatting the file will fail the build I guess

Avoid work when there are no dependencies
@jjkester
Copy link
Contributor Author

Reverted the accidental reformat, force-of-habit hotkey in IntelliJ...

Extract method, re-introduce optimization to return original model
Copy link
Contributor

@mthmulders mthmulders left a comment

Choose a reason for hiding this comment

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

The changes make sense to me. I'm happy to see the added IT's have passed, proving the bug is fixed.

@gnodet
Copy link
Contributor

gnodet commented Oct 19, 2024

The changes make sense to me. I'm happy to see the added IT's have passed, proving the bug is fixed.

For the IT to run, a branch in the maven-integration-testing fork with the same name than this branch and in the same org must exists.

@jjkester
Copy link
Contributor Author

jjkester commented Oct 19, 2024

@gnodet There is a branch with an additional integration test (contributed by @mthmulders) which is being run in the pipeline for this PR. The PR for the integration test is apache/maven-integration-testing#393

@mthmulders
Copy link
Contributor

mthmulders commented Oct 19, 2024

For the IT to run, a branch in the maven-integration-testing fork with the same name than this branch and in the same org must exists.

This is exactly what is happening: look for MavenITmng8331VersionedAndUnversionedDependenciesTest in this pipeline.

@cstamas cstamas merged commit 84ed8be into apache:master Oct 19, 2024
13 checks passed
@jjkester jjkester deleted the mng-8331 branch October 19, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants