refreshVersions icon indicating copy to clipboard operation
refreshVersions copied to clipboard

Use RefreshVersions within ResolutionStrategy

Open alandoni opened this issue 3 years ago • 7 comments

⚠️ Is your feature request related to a problem? Please describe

I need to use ResolutionStrategy on my project so I can force some versions of the libraries I am using, for example:

configurations.all {
    resolutionStrategy.force(Libs.recyclerview)
}

But this code is throwing an error because the gradle is not getting the version from versions.properties

💡 Describe the solution you'd like

I want the library inside resolutionStrategy.force() to be resolved as any dependency

🤚 Do you want to develop this feature yourself?

  • [ ] Yes
  • [X] No

alandoni avatar Apr 19 '22 17:04 alandoni

I hit an error with this today. Was very confusing. As a stop-gap, don't have refreshVersions migrate replace this if it can't do anything about it. :-)

toddobryan avatar Aug 16 '22 23:08 toddobryan

The migration task is currently not designed to be perfect, it does, say, 90% of the job, and you do the remaining 10%.

Now, the next version (release in a few days) will support updating dependencies referenced in versionFor, so this use case will be supported, albeit not migrated automatically for the time being.

LouisCAD avatar Aug 17 '22 13:08 LouisCAD

@toddobryan we are not going to do this sorry

An alternative is to do something like this:

dependencies {
   implementation("com.group:my-lib:" + versionFor("version.xxx"))
}

See https://jmfayard.github.io/refreshVersions/add-dependencies/#get-the-version-from-anywhere

jmfayard avatar Sep 13 '22 21:09 jmfayard

Re-opening because I think we want to avoid the migration task to mess with this as @toddobryan pointed out.

LouisCAD avatar Sep 14 '22 00:09 LouisCAD

@alandoni I tried to reproduce the problem and ideed got an issue. Can you confirm that it was was you were experiencing?

See https://github.com/jmfayard/refreshVersions/commit/74697b49c8a0c7c51921fdbb91c2dd30dad92352

jmfayard avatar Sep 14 '22 06:09 jmfayard

yes, this is the issue

Em qua., 14 de set. de 2022 às 03:11, Jean-Michel Fayard < @.***> escreveu:

@alandoni https://github.com/alandoni I tried to reproduce the problem and ideed got an issue. Can you confirm that it was was you were experiencing?

See 74697b4 https://github.com/jmfayard/refreshVersions/commit/74697b49c8a0c7c51921fdbb91c2dd30dad92352

— Reply to this email directly, view it on GitHub https://github.com/jmfayard/refreshVersions/issues/541#issuecomment-1246288292, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADBJLDEUBRJZBICON64BIY3V6FT75ANCNFSM5TZO3HBQ . You are receiving this because you were mentioned.Message ID: @.***>

alandoni avatar Sep 14 '22 17:09 alandoni

Yeah. I would be really impressed if the migration tool could handle this. I was just suggesting that it "first do no harm." When you have to force a certain version, it's usually the case that you're stuck using an older version because of some incompatibility or a newer version because somebody found a vulnerability in a package one of your dependencies depends on. (We've had both. Having to use an older version of Scala because newer versions were incompatible with the Kotlin compiler and a newer version of Xerces because one of our dependencies was using a version that had an identified vulnerability.)

If you're in resolutionStrategy.force, it doesn't make as much sense to store these in a versions file, because you can't really refresh the versions when you'd like. That's what force means.

toddobryan avatar Sep 20 '22 02:09 toddobryan