https://kotlinlang.org logo
#refreshversions
Title
# refreshversions
d

dave08

02/08/2022, 1:55 PM
@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

Nikky

02/09/2022, 2:54 PM
try
.absoluteFile
maybe ?
that way resolving it from anywhere else will not change the path
d

dave08

02/09/2022, 2:55 PM
That might be an idea! I'll give it a try.
n

Nikky

02/09/2022, 3:07 PM
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

dave08

02/09/2022, 4:06 PM
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

louiscad

02/09/2022, 4:07 PM
I think it's a safeargs plugins issue where it's not compatible with latest AGP.
d

dave08

02/09/2022, 4:09 PM
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

louiscad

02/09/2022, 4:10 PM
I'd try with AGP 7.0 if possible
Or 7.0.3 I think
d

dave08

02/09/2022, 4:11 PM
Before I just upgraded to 2.4.1..
l

louiscad

02/09/2022, 4:11 PM
Which refreshVersions version are you on?
d

dave08

02/09/2022, 4:12 PM
latest
l

louiscad

02/09/2022, 4:12 PM
The one released last weekend?
Are you using Gradle configuration cache?
d

dave08

02/09/2022, 4:12 PM
yes. not that I know
l

louiscad

02/09/2022, 4:14 PM
I'd try running a Gradle clean in the included build, then in the other build
d

dave08

02/09/2022, 4:32 PM
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

louiscad

02/09/2022, 4:33 PM
Can you print the asbolute path in the Gradle script, to ensure it's the path you are expecting?
d

dave08

02/09/2022, 4:33 PM
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

louiscad

02/09/2022, 4:35 PM
Can you print the asbolute path in the Gradle script, to ensure it's the path you are expecting?
d

dave08

02/09/2022, 4:37 PM
Oh... /home/david/.gradle/daemon/7.3.3/./versions.properties
l

louiscad

02/09/2022, 4:39 PM
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

dave08

02/09/2022, 4:44 PM
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

louiscad

02/09/2022, 4:45 PM
Getting better. Are the repositories properly declared in both projects?
d

dave08

02/09/2022, 4:45 PM
It seems like refreshVersions task has a different way of locating things as the actual dep resolution?
l

louiscad

02/09/2022, 4:45 PM
I'm not sure what you mean by "locating things"
d

dave08

02/09/2022, 4:46 PM
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

louiscad

02/09/2022, 4:49 PM
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

dave08

02/09/2022, 4:51 PM
Copy code
id("de.fayard.refreshVersions") version "0.40.1"
in both projects
l

louiscad

02/09/2022, 4:52 PM
Thank you 🙂 About the repositories, did you check?
d

dave08

02/09/2022, 4:52 PM
Which repositories?
l

louiscad

02/09/2022, 4:53 PM
In Gradle
Copy code
repositories {
    ... // <-- what you have here
}
And possibly the
dependencyResolutionManagement
block in
settings.gradle[.kts]
d

dave08

02/09/2022, 4:55 PM
Same repositories in both projects
l

louiscad

02/09/2022, 4:55 PM
blob thinking fast
d

dave08

02/09/2022, 4:56 PM
It works when I don't try changing the path...
but with project B's version.properties
l

louiscad

02/09/2022, 4:57 PM
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

Nikky

02/09/2022, 8:47 PM
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

louiscad

02/09/2022, 8:48 PM
n

Nikky

02/09/2022, 8:50 PM
questions.. i have questions...
l

louiscad

02/09/2022, 9:00 PM
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.
4 Views