This message was deleted.
# community-support
s
This message was deleted.
c
not understanding what the issue is? Routinely use the generated accessors with no issues, and no use of accessor imports.
2
e
Maybe because I'm using the
kotlin-dsl
plugin?
To be clear, this isn't in build scripts.
c
using that extensively myself. until you mentioned it, was unaware of the accessors import. Accessors, however, aren’t supported outside of build scripts (somewhere in the docs it states this). For plugins, you can do, for example:
Copy code
val implementation by configurations
…to get
implementation
in scope. Alternately, you can stringly-type it via:
Copy code
dependencies {
   "implementation"("my.coordinates:1.2.3")
}
Only the main project build scripts and precompiled project script plugins have type-safe model accessors. Initialization scripts, settings scripts, script plugins do not. These limitations will be removed in a future Gradle release.
https://docs.gradle.org/current/userguide/kotlin_dsl.html#type-safe-accessors
e
Ok I lied when I said it's not a build script 😅 It's a precompiled build script, so autocomplete suggests the accessors. That's why I added a check to now allow them.
c
i see. can’t advise much there, don’t use precompiled scripts myself (find them an awkward in-between with various challenges)
v
Using type-safe accessors is perfectly fine and working great, also in precompiled build scripts. Using explicit imports for the accessors though is totally wrong. Sometimes the IDE thinks it is a good idea to insert the import, but it is not. Whenever the IDE adds such an import, you should open a bug report. Having a rule that prevents commits with such accessor imports is perfectly fine and the fix is to just remove the import.
e
Interesting, I'll check that out and file a bug is appropriate. It seems like the IDE can't find a reference without the import, but I never actually tried building in that state.
@Vampire just got back to this, and if I remove the accessor import, building from the command line fails saying there's an unresolved reference
This is happening across the board, with every reference that is coming from an accessor
c
unusual. would you have a minimal reproduction showing the issue?
e
I simplified it as much as possible
c
sweet thx.
v
Where should it complain about what when you do what @Eli Graber? If I unzip the archive and Sync or do
gw build
, it complains that it cannot select the right variant for
com.eygraber.gradle.utils
e
I think it needs Java 17 to run
c
it does, failing for me in finding Java 17 Azul JVM, installing that now.
v
Ah, you made your plugin require Java 17 as Gradle-running JRE o_O
e
Yeah it's mostly for internal stuff so I was OK with that 😅
c
is this the error relating to accessors:
Copy code
➜  accessor-repro gw build
Starting a Gradle Daemon, 3 incompatible Daemons could not be reused, use --status for details
Type-safe project accessors is an incubating feature.

> Task :compileKotlin FAILED
e: /Users/chrislee/IdeaProjects/repro/accessor-repro/src/main/kotlin/com.example-compose.gradle.kts: (2, 5): Unresolved reference: implementation

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details
e
Yup
v
Well, that script does not apply any plugins, so no type-safe accessors are generated for it
You can accidentally use it with import because of my hack-around for the catalog usage in the precompiled script plugins it seems
c
Copy code
plugins {
    java
}
dependencies {
    implementation("androidx.compose:compose-bom:2022.11.00")
}
that works.
v
So you use the accessor made for the outer project that you forward using the
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
line
So TL;DR as Chris said, apply the plugin you want to configure and you will also have the proper accessors available.
e
🙈 Can't believe I missed that, thanks guys!
👌 1
👍 1