This message was deleted.
# community-support
s
This message was deleted.
c
probably through
rootproject
z
that returns a
ProjectDescriptor
- which only has APIs for
File
. And
settings
scripts do not have access to
ObjectFactory
c
it's not mine, but I was told that
gradle.rootProject.layout
is the solution
z
ahh -
gradle.rootProject.layout
is different, so yes that works, assuming accessing
Gradle
is okay
Copy code
Could not create provider for value source Settings_gradle.BuildScanStartParametersValueSource.
> The root project is not yet available for build.
nope 😞
j
Copy code
providers.gradleProperty(…)
z
I’m trying to get a
Provider<FileContents>
for the root
gradle.properties
within
settings.gradle.kts
. This requires a
RegularFile
as input
v
Actually why? Assuming a typical layout where the settings directory is in the same directory as the root project directory, you can simply access the Gradle properties. If you tell what you want to achieve, you might get better recommendations.
it's not mine, but I was told that
gradle.rootProject.layout
is the solution
That cannot work as the root project is not yet available when the settings script is evaluated. Hence the exception he got. You could only do it in a delayed action like with
gradle.rootProject { ... }
or similar.
👍 1
z
Ah, didn't realize there was a lambda!
a
It seems that you can get
ObjectFactory
in
settings.gradle.kts
in some way, if that helps (from gradle#14171):
Copy code
import org.gradle.kotlin.dsl.support.serviceOf
...
val objects = gradle.serviceOf<ObjectFactory>()
👍 1
v
Is
serviceOf
now considered public API @Anze Sodja? Cédric told me it is internal API even if not in an internal package only meant for implementation of version catalogs when I recommended it in build scripts.
a
Yeah good point, status of that hasn’t change yet. So I wouldn’t recommend it for some public plugin that has to support multiple Gradle versions.
v
I still find it very strange that it is in a public package but considered internal, maybe it should be moved as long as it is not considered public api. 😉
1
a
Yeah, that is unfortunate. For Kotlin DSL we have a note about that in docs: https://docs.gradle.org/nightly/userguide/kotlin_dsl.html#sec:implicit_imports. But we should do that better, definitely.
v
Oh, I think I never have seen that note. And even if, I would have forgotten and probably just look for
.internal.
in the package name probably. :-(
1