<@U3ZLHBTLG> I tried the code in the thread and th...
# refreshversions
d
@louiscad I tried the code in the thread and the
refreshVersions
task on the main project still updates the
versions.properties
in mylib instead of the one in the setting.gradle.kts's path in the main project... is there any workaround?
🧵 2
Copy code
// settings.gradle.kts in the MAIN project, not the one in mylib...

refreshVersions {
    enableBuildSrcLibs()

    versionsPropertiesFile = File("./versions.properties")
}

enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

include(":app")

includeBuild("../mylib")
n
try
.absoluteFile
maybe ?
that way resolving it from anywhere else will not change the path
d
That might be an idea! I'll give it a try.
n
i think internally it might just assume the highest project up in the filetree is the root or such.. i will dig into the code later and see if i can pinpoint the fault.. (i bet the entire codebase changed from last time i had a look at it)
d
Thanks for looking into this 👍🏼! It looks like something changed... I suddenly got this error:
Copy code
com/android/build/api/extension/AndroidComponentsExtension

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
java.lang.NoClassDefFoundError: com/android/build/api/extension/AndroidComponentsExtension
	at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:73)
	at androidx.navigation.safeargs.gradle.SafeArgsPlugin.apply(SafeArgsPlugin.kt:42)
...
it could be it's now looking at the other versions.properties file and starting to find problems with deps...
l
I think it's a safeargs plugins issue where it's not compatible with latest AGP.
d
7.1.1? I upgraded before this in BOTH projects (but had safeargs in the plugins block commented)... before I switched to
absoluteFile
, once I switched, this error appeared...
l
I'd try with AGP 7.0 if possible
Or 7.0.3 I think
d
Before I just upgraded to 2.4.1..
l
Which refreshVersions version are you on?
d
latest
l
The one released last weekend?
Are you using Gradle configuration cache?
d
yes. not that I know
l
I'd try running a Gradle clean in the included build, then in the other build
d
Copy code
classpath(AndroidX.navigation.safeArgsGradlePlugin.withVersion("2.5.0-alpha01"))
seems to work, but versions.properties still from project B... even WITH absoluteFile...
l
Can you print the asbolute path in the Gradle script, to ensure it's the path you are expecting?
d
Though I didn't see any
plugin.{...}
for safeArgs in either... I needed to add the withVersion for it to work.
Wow... I think it's completely ignoring the versions.properties from BOTH... I have Kotlin at 1.5.32 in BOTH and it just upgraded me to 1.6...
Even though the refreshVersions task updates project B
l
Can you print the asbolute path in the Gradle script, to ensure it's the path you are expecting?
d
Oh... /home/david/.gradle/daemon/7.3.3/./versions.properties
l
Looks like it's not the right place 🧐
Now, I think it's because of the dot and the leading slash, that's not the right way to refer to the current directory
And you're using
File(…)
from
<http://java.io|java.io>
instead of
file(…)
from Gradle which will be a relative link (granted you don't put
./
at the beginning of your path.
If you want to refer to a parent directory, you can use
rootDir.parent!!
, then
.resolve(…)
d
I tried
versionsPropertiesFile = rootProject.projectDir.absoluteFile.resolve("versions.properties")
which seems to print the right path... but I get: * What went wrong: Execution failed for task ':refreshVersions'.
Can't get latest most stable version in an empty list
l
Getting better. Are the repositories properly declared in both projects?
d
It seems like refreshVersions task has a different way of locating things as the actual dep resolution?
l
I'm not sure what you mean by "locating things"
d
Are the repositories properly declared in both projects?
each project has their own deps. It was working with project B's versions.properties before I changed the path... locating the versions.properties?
l
Anyway, trying to answer what I guess you need to know: refreshVersions looks for versions in the configured
versions.properties
file or what's provided, and if it finds the version when Gradle decides it's time to look at the dependencies of a project, fine, otherwise, it'll block that Gradle callback while it tries to find the latest most stable version. If it can't find the right version, e.g. because no correct repositories has been defined, or because none have the declared artifact, it fails.
@dave08 Can you copy paste the exact version of refreshVersions you are using here, not just because I want to be 100% sure, but also for future reference?
d
Copy code
id("de.fayard.refreshVersions") version "0.40.1"
in both projects
l
Thank you 🙂 About the repositories, did you check?
d
Which repositories?
l
In Gradle
Copy code
repositories {
    ... // <-- what you have here
}
And possibly the
dependencyResolutionManagement
block in
settings.gradle[.kts]
d
Same repositories in both projects
l
blob thinking fast
d
It works when I don't try changing the path...
but with project B's version.properties
l
It's getting too complicated for me to follow the possibilities, can you please make a minimized reproducing project and open an issue on GitHub?
n
looking at this again (even before you had those unexplainable cache failures) i think the last state of support on
includeBuild
that i know of is .. not supported i tried to implement that myself a while back but.. gradle is weird
because of how refreshVersions applies itself.. included builds are tricky to support.. or at least have been in the past..
l
n
questions.. i have questions...
l
Well, Gradle has been named as a pain point in KMM by a fair share of people in the surveys conducted by JetBrains, so making Kotlin more build-agnostic gained some interest as a result. I can see Google making it harder with the state of Android tooling that is centered around the Android Gradle Plugin and Android Studio which is quite tightly coupled to it.