What does ```Caused by: java.lang.UnsupportedOpera...
# compiler
v
What does
Copy code
Caused by: java.lang.UnsupportedOperationException: Don't know how to generate outer expression for public constructor `<no name provided>`() defined in Build_gradle.`<init>`.`<anonymous>`.`<anonymous>`.`<anonymous>`.`<anonymous>`.`<anonymous>`.`<no name provided>`[DefaultClassConstructorDescriptor@386391e8]
want to tell me and how do I make it work? 😕
🤕 1
This is in a Gradle 7.6.4 build that cannot be updated so with Kotlin 1.7.10. With Gradle 8.0 and thus Kotlin 1.8.10 it starts working.
But what is its problem?
This is what triggers it:
Copy code
testing {
    suites {
        val test by existing(JvmTestSuite::class) {
            targets.configureEach {
                testTask {
                    jvmArgumentProviders.add(
                        object : CommandLineArgumentProvider {
                            @InputFiles
                            @PathSensitive(RELATIVE)
                            val scratchDirectory = layout.projectDirectory / "src" / "main" / "scratch"

                            override fun asArguments() = listOf("-DscratchDirectory=${scratchDirectory.asFile.absolutePath}")
                        }
                    )
                }
            }
        }
    }
}
d
It's probably KT-54875
v
Hm, well, that error just says "many things were fixed, should work better now", so doesn't help too much 😄
I can even boil it down to
Copy code
val scratchDirectoryArgumentProvider = object : CommandLineArgumentProvider {
    val scratchDirectory = layout.projectDirectory
    override fun asArguments() = emptyList<String>()
}
While
Copy code
val scratchDirectoryArgumentProvider = object : CommandLineArgumentProvider {
    val scratchDirectory = "layout.projectDirectory"
    override fun asArguments() = emptyList<String>()
}
works
Ah,
Copy code
val projectDirectory = layout.projectDirectory
val scratchDirectoryArgumentProvider = object : CommandLineArgumentProvider {
    val scratchDirectory = projectDirectory
    override fun asArguments() = emptyList<String>()
}
also works, that might be a viable work-around until Gradle 8 upgrade is possible
Thanks for rubber-ducking 😄
👌 1
Yes, this works:
Copy code
testing {
    suites {
        val test by existing(JvmTestSuite::class) {
            targets.configureEach {
                testTask {
                    val projectDirectory = layout.projectDirectory
                    jvmArgumentProviders.add(
                        object : CommandLineArgumentProvider {
                            @InputFiles
                            @PathSensitive(RELATIVE)
                            val scratchDirectory = projectDirectory / "src" / "main" / "scratch"

                            override fun asArguments() = listOf("-DscratchDirectory=${scratchDirectory.asFile.absolutePath}")
                        }
                    )
                }
            }
        }
    }
}
👍 1