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. (https://github.com/xamarin/AndroidX/issues/764)
A wrinkle is that we use <ProjectReference> to create our dependency tree and it does not currently support specifying an "exact" version dependency. https://github.com/NuGet/Home/issues/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.
This should help mitigate future errors caused by types moving between Java packages that should always have synced versions.
Context: https://github.com/xamarin/AndroidX/issues/764
Today,
binderator
enforces "exact dependencies" specified in POM files. If you do not fulfill them you get this error: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
. (https://github.com/xamarin/AndroidX/issues/764)A wrinkle is that we use
<ProjectReference>
to create our dependency tree and it does not currently support specifying an "exact" version dependency. https://github.com/NuGet/Home/issues/5556A workaround is to use a custom target in
Directory.Build.targets
that allows aExactVersion="true"
attribute to be added to a<ProjectReference>
. This attribute is then taken into account when NuGetpack
is run.This should help mitigate future errors caused by types moving between Java packages that should always have synced versions.