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

Intermodule dependency on -SNAPSHOT qualifier conflicts with BinaryAndSourceCompatibility setting #155

Closed
seigert opened this issue Mar 7, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@seigert
Copy link

seigert commented Mar 7, 2023

We have a project with two modules: api, client.dependsOn(api). They share same version setting: ThisBuild / version := "1.2.1-SNAPSHOT".

If we use BinaryAndSourceCompatible compatibility settings we get following error on versionPolicyCheck:

[error] Incompatibilities with dependencies of client:1.2.0
[error]   api_2.13: incompatible version change from 1.2.0 to 1.2.1-SNAPSHOT (compatibility: strict semantic versioning)
[info] Module api:1.2.1-SNAPSHOT has no dependency issues with version 1.2.0 (versionPolicyIntention is set to 'Compatibility.BinaryAndSourceCompatible')
[info] Module client:1.2.1-SNAPSHOT is binary and source compatible with version 1.2.0

Setting either version to 1.2.1, compatibility to BinaryCompatible or adding versions with qualifier to versionPolicyIgnoredInternalDependencyVersions resolves this error.

What is strange to me is that version of client in error above is 1.2.0, i.e. taken from previous artefacts.

@julienrf
Copy link
Collaborator

julienrf commented Mar 7, 2023

versionPolicyCheck checks that the dependencies of the current version of the module client don’t break the compatibility guarantees (as per versionPolicyIntention) with respect to the dependencies of the previous version of the module client, which in your case is the version 1.2.0. Hence the message “Incompatibilities with dependencies of client:1.2.0”. The reported incompatibility is that the dependency to the module api changed from version 1.2.0 to version 1.2.1-SNAPSHOT, and sbt-version-policy does not know how to compare a stable version number with a pre-release version number. That’s why changing the version to 1.2.1 does work.

Changing the compatibility intention to BinaryCompatible works because the check is slightly different: we delegate to Coursier, whose algorithm seems to support the -SNAPSHOT suffix. I am tempted to say that we should probably align both behaviors (with BinaryCompatible and BinaryAndSourceCompatible), and probably it makes sense to just ignore the -SNAPSHOT part (or any pre-release identifier or metadata part). We could achieve this by adapting the code here to not require exactly 3 items, but at least 3 items. We would also have to update the test cases here.

What do you think?

@julienrf julienrf added the bug Something isn't working label Mar 7, 2023
@seigert
Copy link
Author

seigert commented Jul 28, 2023

Sorry for the long wait, I'm in full agreement with your proposed changes. I'll try to find time to implement it.

seigert pushed a commit to seigert/sbt-version-policy that referenced this issue Jul 28, 2023
@sjrd sjrd closed this as completed in 3738510 Aug 3, 2023
sjrd added a commit that referenced this issue Aug 3, 2023
fix #155 by extracting version without suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants