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

Add support for exact version NuGet dependencies #770

Merged
merged 2 commits into from
Oct 19, 2023
Merged

Conversation

jpobst
Copy link
Contributor

@jpobst jpobst commented Aug 1, 2023

Context: #764

Today, binderator enforces "exact dependencies" specified in POM files. If you do not fulfill them you get this error:

System.Exception: 
No matching artifact config found for: 
    androidx.preference.preference:[1.2.0]
to satisfy dependency of: 
    androidx.preference.preference-ktx:1.2.0

However, when we create NuGets we ignore this requirement and instead allow a "greater than or equal to" dependency. When types move from one package to another and the package versions are not kept locked, it can result in errors like Type androidx.lifecycle.DispatchQueue is defined multiple times. (#764)

A wrinkle is that we generally use <ProjectReference> to create our dependency tree and it does not currently support specifying an "exact" version dependency. NuGet/Home#5556

A workaround is to use a custom target in Directory.Build.targets that allows a ExactVersion="true" attribute to be added to a <ProjectReference>. This attribute is then taken into account when NuGet pack is run.

Some references are dependencyOnly: true. These are specified using <PackageReference> so we also need to support specifying exact references there as well.

This should help mitigate future errors caused by types moving between Java packages that should always have synced versions.

An additional requirement is that the exact version should only apply to the Java version piece of our NuGet versions. That is, if the Java version is locked to [1.2.0], we should still allow the user to use NuGet versions like 1.2.0.7. This will be expressed as [1.2.0,1.3.0).

CI Example of <ProjectReference>:

image

CI Example of <PackageReference>:

image

@jpobst jpobst marked this pull request as ready for review August 3, 2023 14:25
@jpobst jpobst requested a review from moljac August 3, 2023 14:25
Copy link
Member

@moljac moljac left a comment

Choose a reason for hiding this comment

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

LGTM

@jpobst jpobst merged commit cd26694 into main Oct 19, 2023
4 checks passed
@jpobst jpobst deleted the exact-versions branch October 19, 2023 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants