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

[MENFORCER-427] New rule to ban dynamic versions #187

Merged
merged 6 commits into from
Oct 14, 2022

Conversation

kwin
Copy link
Member

@kwin kwin commented Oct 11, 2022

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 [MENFORCER-XXX] - Fixes bug in ApproximateQuantiles,
    where you replace MENFORCER-XXX with the appropriate JIRA issue. Best practice
    is to use the JIRA issue title in 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 integration tests successfully (mvn -Prun-its clean verify).

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 force-pushed the feature/MENFORCER-427-ban-version-ranges branch from 44b3d04 to 9bbca7a Compare October 11, 2022 17:53
@kwin kwin force-pushed the feature/MENFORCER-427-ban-version-ranges branch from 9bbca7a to 5e850dc Compare October 11, 2022 18:05
@michael-o
Copy link
Member

Here are edge cases which I expect to work:

@kwin
Copy link
Member Author

kwin commented Oct 12, 2022

  • [1.0.0,1.0.0] is currently invalid and leads to org.apache.maven.artifact.versioning.InvalidVersionSpecificationException: Range cannot have identical boundaries: [1.0,1.0].
  • [1.0] leads to version resolving (although redundant) when used in a dependency and therefore always means overhead during build and dependency on metadata. I would rather ban this as well. This should be replaced by soft requirement 1.0 to speed up the build! Is there already an issue related to this? According to https://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification the fixed hard requirement may make sense for some edge cases, but as long as this leads to version resolving I would recommend not to rely on it.

@kwin
Copy link
Member Author

kwin commented Oct 12, 2022

I opened https://issues.apache.org/jira/browse/MNG-7561 for same lower and upper bounds but it seems using a hard restriction always require resolving against metadata from local/remote repo, therefore at least optionally this pattern should be banned as well in this rule.

@michael-o
Copy link
Member

michael-o commented Oct 13, 2022

  • [1.0.0,1.0.0] is currently invalid and leads to org.apache.maven.artifact.versioning.InvalidVersionSpecificationException: Range cannot have identical boundaries: [1.0,1.0].

    • [1.0] leads to version resolving (although redundant) when used in a dependency and therefore always means overhead during build and dependency on metadata. I would rather ban this as well. This should be replaced by soft requirement 1.0 to speed up the build! Is there already an issue related to this? According to https://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification the fixed hard requirement may make sense for some edge cases, but as long as this leads to version resolving I would recommend not to rely on it.

@cstamas @gnodet What is your opinion on this?

@michael-o
Copy link
Member

michael-o commented Oct 13, 2022

  • [1.0.0,1.0.0] is currently invalid and leads to org.apache.maven.artifact.versioning.InvalidVersionSpecificationException: Range cannot have identical boundaries: [1.0,1.0].

This is strange because 1.0 is resolved to this...I wonder why this range is logically invalid.

  • [1.0] leads to version resolving (although redundant) when used in a dependency and therefore always means overhead during build and dependency on metadata. I would rather ban this as well. This should be replaced by soft requirement 1.0 to speed up the build! Is there already an issue related to this? According to https://maven.apache.org/pom.html#Dependency_Version_Requirement_Specification the fixed hard requirement may make sense for some edge cases, but as long as this leads to version resolving I would recommend not to rely on it.

Well, [1.0] exists for a reason. I think it is parsed to [1.0,1.0] then of course it incurs resolution. Hard for me to tell whether this should be blocked or not. If you want to block this, fine. Add a comment about the situation.

@kwin
Copy link
Member Author

kwin commented Oct 13, 2022

This is strange because 1.0 is resolved to this...I wonder why this range is logically invalid.

I proposed a fix for this attached to https://issues.apache.org/jira/browse/MNG-7106

@kwin
Copy link
Member Author

kwin commented Oct 13, 2022

I think it is parsed to [1.0,1.0] then of course it incurs resolution.

This is totally unexpected because 1.0 (soft requirement) is not resolved, see also my comment at apache/maven#823 (comment).
The only difference between [1.0] and 1.0 should be that one is a hard requirement the other one a soft one (https://maven.apache.org/pom.html#dependency-version-requirement-specification). The documentation doesn't say anything that hard requirements are resolved while soft ones aren't.

@michael-o
Copy link
Member

I think it is parsed to [1.0,1.0] then of course it incurs resolution.

This is totally unexpected because 1.0 (soft requirement) is not resolved, see also my comment at apache/maven#823 (comment). The only difference between [1.0] and 1.0 should be that one is a hard requirement the other one a soft one (https://maven.apache.org/pom.html#dependency-version-requirement-specification). The documentation doesn't say anything that hard requirements are resolved while soft ones aren't.

My bad, I meant [1.0]

kwin added 3 commits October 13, 2022 14:52
optionally allow same upper and lower bounds
include optional dependencies by default
@michael-o michael-o self-requested a review October 13, 2022 13:47
@kwin kwin merged commit 3c74747 into master Oct 14, 2022
@kwin kwin deleted the feature/MENFORCER-427-ban-version-ranges branch October 14, 2022 06:40
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