How to overwrite version from catalog

I have a catalog remote repository, which is publish by the gradle-catalog plugin.

//settings.gradle.kts
versionCatalogs {
        create("remotes") {
            from("com.betalpha:betalpha-catalog:1.0.13")
            // overwrite
            version("betalpha-formula-v4", "0.0.24")
            version("betalpha-beyond", "2.1.9")
        }
    }

I am not sure that this is the correct way to do that. Even I am not sure it that possible to overwrite it. But it did works weeks ago in my project. Now, it seem not work, when I am trying to get the betalpha.beyond version in build.gradle.kts. I will get exception like this:

//build.gradle.kts
val beyondVersion = remotes.versions.betalpha.beyond.get()
e: file:///Users/ovo-copy/IdeaProjects/bar-backend/build.gradle.kts:99:58: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: 
public inline operator fun <K, V> Map<out TypeVariable(K), TypeVariable(V)>.get(key: TypeVariable(K)): TypeVariable(V)? defined in kotlin.collections
public operator fun MatchGroupCollection.get(name: String): MatchGroup? defined in kotlin.text
public operator fun <T : Any> NamedDomainObjectCollection<TypeVariable(T)>.get(name: String): TypeVariable(T) defined in org.gradle.kotlin.dsl
public operator fun ExtensionContainer.get(name: String): Any defined in org.gradle.kotlin.dsl
public inline fun <S : Any, T : SoftwareComponent> BinaryCollection<TypeVariable(T)>.get(type: KClass<TypeVariable(S)>, spec: Spec<in TypeVariable(S)>): BinaryProvider<TypeVariable(S)> defined in org.gradle.kotlin.dsl

seems like it cannot know which function it should use.

Did you maybe add a betalpha-beyond-whatever version since it worked?
Because then remotes.versions.betalpha.beyond is a hybrid on which you can get remotes.versions.betalpha.beyond.whatever or the version itself with remotes.versions.betalpha.beyond.asProvider() on which you then can call the get().

1 Like

Yeah, at the first time. I did thought that it could be this problem. And I checked this generated code by Gradle, which leads me to the function getBeyond() with a Provider<String> returning.

But as you mentioned this, I tried to reopen my idea project, and reload any build caches. And Tada. IT IS this problems. Now it returns VersionAccessors from the same method. Seems like the cache did not refresh correctly.

Thanks, you are so kind to give me advices. And sorry for the wasting of time. I was trying to figure out this problem for one hour, and thought it could be something extreme wired, or edge cases nobody met before. Yeah. I was wrong.

1 Like