Error while trying out the libs.versions.toml functionality

Hello,

My team uses a very similar pattern to the libs.versions.toml patter that is available as a preview feature. While attempting to use this functionality I ran into a problem where some libraries cause conflicts that I’m not totally sure how to resolve.

For example:

[versions]
kafka = "2.6"

[libraries]
kafka_streams = { module = "org.apache.kafka:kafka-streams", version.ref = "kafka"}
kafka_streams_test_utils = { module = "org.apache.kafka:kafka-streams-test-utils", version.ref = "kafka"}

Causes this error:

org.gradle.api.InvalidUserDataException: Cannot generate accessors for kafka because it contains both aliases and groups of the same name: [streams]
> Cannot generate accessors for kafka because it contains both aliases and groups of the same name: [streams]

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

I know this is just in preview so I’m not getting my heart too set on it right now, but I don’t even know where to begin to troubleshoot this. Anyone have any insights into why this might be happening?

When you use these dependencies, you’d write something like:

dependencies {
    implementation libs.kafka.streams
    testImplementation libs.kafka.streams.test.utils
}

The issue here being that libs.kafka.streams is an alias to a library, but it’s also a group because libs.kafka.streams.test.utils starts with libs.kafka.streams. Renaming these to not conflict is required in the current version.

However, this should no longer be an issue once 7.2 is released. You can experiment with how it works after the fix in the latest nightly as well.

Ok, yeah that makes sense. I really like the direction that this functionality is headed, I look forward to 7.2.