Gradle always resolves my local artifact as a dependency even when the version is wrong (new)

I have exactly the problem described in the old forum: a Gradle script that uses a previously released version of its own artifact as a dependencyis always resolved with the current version.

To my dismay I found that the solution proposed there (use force true) stops working with gradle 4.8 and beyond.

Is there a new solution to this problem?