You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "jjkester (via GitHub)" <gi...@apache.org> on 2024/10/19 07:25:41 UTC

[PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

jjkester opened a new pull request, #1821:
URL: https://github.com/apache/maven/pull/1821

   Following this checklist to help us incorporate your
   contribution quickly and easily:
   
    - [X] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) 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.
    - [X] Each commit in the pull request should have a meaningful subject line and body.
    - [X] Format the pull request title like `[MNG-XXX] SUMMARY`,
          where you replace `MNG-XXX` and `SUMMARY` with the appropriate JIRA issue.
    - [X] 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.
    - [X] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
    - [X] 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][core-its] successfully.
   
   If your pull request is about ~20 lines of code you don't need to sign an
   [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) 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](http://www.apache.org/licenses/LICENSE-2.0)
   you have to acknowledge this by using the following check-box.
   
    - [X] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   
    - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
   
   [core-its]: https://maven.apache.org/core-its/core-it-suite/
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423706643

   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas merged PR #1821:
URL: https://github.com/apache/maven/pull/1821


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "jjkester (via GitHub)" <gi...@apache.org>.
jjkester commented on code in PR #1821:
URL: https://github.com/apache/maven/pull/1821#discussion_r1807256540


##########
maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java:
##########
@@ -564,20 +564,21 @@ public void mergeRepositories(List<Repository> toAdd, boolean replace) {
         // Infer inner reactor dependencies version
         //
         Model transformFileToRaw(Model model) {
-            List<Dependency> newDeps = new ArrayList<>();
-            boolean modified = false;
+            if (model.getDependencies().isEmpty()) {
+                return model;
+            }
+            List<Dependency> newDeps = new ArrayList<>(model.getDependencies().size());
             for (Dependency dep : model.getDependencies()) {
                 if (dep.getVersion() == null) {
-                    Dependency.Builder depBuilder = null;
                     Model depModel = getRawModel(model.getPomFile(), dep.getGroupId(), dep.getArtifactId());

Review Comment:
   @gnodet I think this part of the code (starting here or below `if (depModel != null)`) is a good candidate for extraction to improve readability. It seems to just apply the new logic to retrieve the version from the aggregated build. However, I do not have a clear name for that method since I'm not familiar with the common terminology. Do you have a suggestion?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "mthmulders (via GitHub)" <gi...@apache.org>.
mthmulders commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423962612

   > 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](https://github.com/apache/maven/actions/runs/11417228901/job/31769368782?pr=1821).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423678570

   There is a more trivial PR https://github.com/apache/maven/pull/1822


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "jjkester (via GitHub)" <gi...@apache.org>.
jjkester commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423701084

   > @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
   
   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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423697074

   @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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423713177

   Ugh, reformatting the file will fail the build I guess


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "mthmulders (via GitHub)" <gi...@apache.org>.
mthmulders commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423655994

   Corresponding IT: https://github.com/apache/maven-integration-testing/pull/393.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "jjkester (via GitHub)" <gi...@apache.org>.
jjkester commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423948749

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "cstamas (via GitHub)" <gi...@apache.org>.
cstamas commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423691501

   Another alternative mixing the two solutions: https://github.com/apache/maven/pull/1823


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "jjkester (via GitHub)" <gi...@apache.org>.
jjkester commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423714644

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on code in PR #1821:
URL: https://github.com/apache/maven/pull/1821#discussion_r1807287840


##########
maven-api-impl/src/main/java/org/apache/maven/internal/impl/model/DefaultModelBuilder.java:
##########
@@ -564,20 +564,21 @@ public void mergeRepositories(List<Repository> toAdd, boolean replace) {
         // Infer inner reactor dependencies version
         //
         Model transformFileToRaw(Model model) {
-            List<Dependency> newDeps = new ArrayList<>();
-            boolean modified = false;
+            if (model.getDependencies().isEmpty()) {
+                return model;
+            }
+            List<Dependency> newDeps = new ArrayList<>(model.getDependencies().size());
             for (Dependency dep : model.getDependencies()) {
                 if (dep.getVersion() == null) {
-                    Dependency.Builder depBuilder = null;
                     Model depModel = getRawModel(model.getPomFile(), dep.getGroupId(), dep.getArtifactId());

Review Comment:
   Good point, I've extracted it in https://github.com/apache/maven/pull/1822



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] [MNG-8331] Sometimes versioned dependencies disappear [maven]

Posted by "gnodet (via GitHub)" <gi...@apache.org>.
gnodet commented on PR #1821:
URL: https://github.com/apache/maven/pull/1821#issuecomment-2423932629

   > 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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org