Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IllegalArgumentException: List has more than one element when BOM is included #112

Open
lydavid opened this issue Aug 19, 2024 · 2 comments
Labels
bug Something isn't working lang:kotlin Kotlin DSL

Comments

@lydavid
Copy link

lydavid commented Aug 19, 2024

Error: Exception in thread "main" java.lang.IllegalArgumentException: List has more than one element.

	at kotlin.collections.CollectionsKt___CollectionsKt.single(_Collections.kt:610)
	at cash.grammar.kotlindsl.utils.DependencyExtractor.findIdentifier(DependencyExtractor.kt:221)
	at cash.grammar.kotlindsl.utils.DependencyExtractor.parseDependencyDeclaration(DependencyExtractor.kt:139)
	at cash.grammar.kotlindsl.utils.DependencyExtractor.collectDependencies(DependencyExtractor.kt:48)

When I remove the BOM, this goes away.

Example build.gradle.kts that failed until I commented out the BOM:

plugins {
    id("ly.david.musicsearch.kotlin.multiplatform")
    alias(libs.plugins.kotlin.serialization)
}

kotlin {
    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation(projects.shared.domain)
                implementation(projects.core.logging.api)
                implementation(libs.koin.core)
//                implementation(project.dependencies.platform(libs.ktor.bom))
                implementation(libs.ktor.client.core)
                implementation(libs.ktor.serialization.kotlinx.json)
            }
        }
        val commonTest by getting {
            dependencies {
                implementation(libs.kotlin.test)
            }
        }
    }
}

There's some GHA runs seen here: lydavid/MusicSearch#1069

@autonomousapps autonomousapps added bug Something isn't working lang:kotlin Kotlin DSL labels Oct 10, 2024
@dees91
Copy link

dees91 commented Oct 18, 2024

I have same issue trying to add

sourceSets {
    androidMain {
        dependencies {
            ...
            implementation(project.dependencies.platform(libs.kotlin.faker.bom))
            ...
        }
    }

@dees91
Copy link

dees91 commented Jan 16, 2025

kind of workaround - create ext function:

fun KotlinDependencyHandler.platformBillsOfMaterials(dependencyProvider: Provider<MinimalExternalModuleDependency>) {
    implementation(project.dependencies.platform(dependencyProvider))
}

and then declare dependency as:

platformBillsOfMaterials(libs.kotlin.faker.bom)

not ideal, but until resolved on the gradle-dependencies-sorter side, sorting works and bom works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lang:kotlin Kotlin DSL
Projects
None yet
Development

No branches or pull requests

3 participants