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

[Improvement]: Simplify the package locking mode deriving logic #42706

Open
gayaldassanayake opened this issue May 8, 2024 · 0 comments
Open
Labels
Area/ProjectAPI Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Improvement

Comments

@gayaldassanayake
Copy link
Contributor

Description

The package locking mode resolution has been distributed among different classes during the package resolution. While this works without any issues, it's a bit confusing. It impacts the readability and the maintainability of the code base.

Describe your problem(s)

In PackageResolution.java, the locking mode resolution logic is as follows.

if dependencies toml exists
    if new distribution version
        locking_mode = SOFT
    else
        locking_mode = MEDIUM
else # fresh project
    if sticky
        locking_mode = MEDIUM
    else 
        locking_mode = SOFT

However, in io.ballerina.projects.internal.ResolutionEngine#resolveDirectDependencies and io.ballerina.projects.internal.ResolutionEngine#getRequestForUnresolvedNode, we have added an additional check to check if sticky flag is on.

locking_mode = sticky? HARD: resolutionOptions.packageLockingMode();

Describe your solution(s)

Instead, we can unify this to be in PackageResolution as follows.

if dependencies toml exists
    if sticky
        locking_mode = HARD
    else if new distribution version
        locking_mode = SOFT
    else
        locking_mode = MEDIUM
else # fresh project
    if sticky
        locking_mode = MEDIUM
    else 
        locking_mode = SOFT

Related area

-> Compilation

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

@ballerina-bot ballerina-bot added needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels May 8, 2024
@gayaldassanayake gayaldassanayake added Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) and removed needTriage The issue has to be inspected and labeled manually userCategory/Compilation labels May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area/ProjectAPI Team/DevTools Ballerina Developer Tooling ( CLI, Test FW, Package Management, OpenAPI, APIDocs ) Type/Improvement
Projects
None yet
Development

No branches or pull requests

2 participants