hydraulic-software / conveyor

Gradle plugin, user guide and discussion forums for Conveyor
https://conveyor.hydraulic.dev
Apache License 2.0
123 stars 10 forks source link

`writeConveyorConfig` throws `Configuration with name 'desktopRuntimeClasspath' not found.` #108

Closed zacharee closed 6 months ago

zacharee commented 6 months ago

Describe the bug In my Compose Multiplatform project, after doing some dependency upgrades, the writeConveyorConfig task fails with Configuration with name 'desktopRuntimeClasspath' not found..

To Reproduce Steps to reproduce the behavior:

  1. Clone the project from the link above.
  2. Run ./gradlew :desktop:writeConveyorConfig.

Expected behavior The task should complete successfully.

Desktop (please complete the following information):

Additional context Looking at the source, I think project.configurations.getByName("desktopRuntimeClasspath") should be project.configurations.findByName("desktopRuntimeClasspath") in ConveyorConfigTask#importFromDependencyConfigurations().

My project does have jvmRuntimeClasspath defined, so Conveyor should be able to use that, but since it calls getByName(), the task fails instead of returning null.

mikehearn commented 6 months ago

I think you're right. Does the following logic look correct?

        val configNames = setOf("runtimeClasspath", "desktopRuntimeClasspath", "jvmRuntimeClasspath")
        val runtimeClasspathConfiguration = try {
            configNames.firstNotNullOf { project.configurations.findByName(it) }
        } catch (e: NoSuchElementException) {
            throw Exception("Could not locate the classpath configuration, tried $configNames")
        }

The Gradle plugin has been extensively refactored on our dev branch to make it compatible with the configuration cache, so I won't apply this patch as-is immediately, but will try to release the new plugin ASAP.

zacharee commented 6 months ago

I think that looks right. I worked around it for now by adding

project.configurations.create("desktopRuntimeClasspath") {
    extendsFrom(project.configurations.findByName("jvmRuntimeClasspath"))
}

to my Gradle config.