I'm using a Gradle composite build for my custom plugins. I'm also using the version catalog for my ...
j
I'm using a Gradle composite build for my custom plugins. I'm also using the version catalog for my dependencies, which I'm also using in my composite build. Every time the composite build module is rebuilt I get the following error:
Copy code
Unresolved reference: versionCatalogs
However everything works fine besides this error. I can build my (android) app without any other problems. The CLI never reports this error. Someone has an idea how to solve this? This is my
settings.gradle.kts
file within the composite build:
Copy code
dependencyResolutionManagement {
    versionCatalogs {
        create("libs") {
            from(files("../gradle/libs.versions.toml"))
        }
    }
}
I'm using the latest stable Gradle Version (7.4.2)
v
Where do you get that false error? From IDE I guess?
j
I think included build can't find the libs by default, it is weird it works via cli
v
If it is the problem I think of it is not weird and I know a solution, just checking whether it is
j
at least I am forced to indicate it in my buildSrc I think
v
He does not have
buildSrc
but uses a composite build. And again, I think I know what his problem is and a work-around, just want to verify first
This is probably the problem you are hitting: https://youtrack.jetbrains.com/issue/IDEA-262528/included-builds-are-run-standalone-with-the-wrong-version-on-%22Bu To solve it create a gradle wrapper properties file (no need for the other three wrapper files) for the included build until that bug is fixed.
j
Sorry for my late reply. Yes I'm getting this error from the IDE. I'm gonna try your workaround 👍
@Vampire Yes this reads exactly like my error (it always happens when I press the green hammer icon). Only that it reports the error I posted above. I'm unsure what you mean with
create a gradle wrapper properties file for the included build
. Where exactly should I put it? I tried
{compositeBuildFolder}/gradle/wrapper/gradle-wrapper.properties
but it doesn't work.
v
Well, for one, don't use the green hammer icon. It usually just wastes time by building things you don't need. But toher than that, yes, in the same place as the file always is. You surely didn't just now create an empty file there, did you?
j
Nah I copied the existing one 😅
It's just the easiest button to reach when I want to trigger the build process 😬
v
Then it should work fine. Did you re-sync the project?
j
yes
v
Try closing and reopening the IDE. It has another bug where stale connections to the Gradle daemon are used instead of with the changed wrapper properties file
👍 1
j
It also occurs after a
clean build
. So there is another usecase 😅
v
clean build shouln't make a difference and actually never be necessary
Whenever you need to use
clean
to get a reliable build result, there is a bug in your build scripts. Gradle is not Maven. 😄 There it was more or less mandatory to always also execute
clean
to get reliable results
j
Ah well. Android Development says otherwise 😅 like kapt bugging around
I'm not needing it for problems with gradle itself
v
Ah, ok AGP can of course destroy it, yeah. Heard many strange things about AGP. I'm happy not to be involved with Android dev so far. 😄
j
😄
But on the good side: Your tips worked 🎉 Thank you so much!
No more error!
v
yw