is it expected that constraints using versions def...
# community-support
r
is it expected that constraints using versions defined in catalog do not work and fail silently?
Copy code
constraints {
    // This works as expected
    api("com.fasterxml.jackson.core:jackson-core") {
        version {
            require(libs.versions.jackson.get())
        }
    }
    // This is does not work at all
    api(libs.jackson.core.get())
}
Tested in Gradle 8.12.0 I am specially worried as it fails silently
v
Why do you have a
get()
there? Does it work if you remove the
get()
? If not, what do you mean by "fail silently", how does the "fail" manifest? Can you share a build
--scan
URL that shows the problem?
r
https://scans.gradle.com/s/6xqpjxwoe52ky This is without get(), the catalog version is defined at 2.18.2 The constraint is at the jvm grpccommon module I added the get() at some point as I was getting an exception with "You shouldn't use a dependency constraint created via a Provider directly" but I am not able to reproduce it anymore. 🤷
Scan with the working constraint: https://scans.gradle.com/s/bcf5xlehyepxs
v
And what are the entries in your version catalog? Does the jackson-core entry maybe not have a version as you get it through the bom or something similar?
r
Copy code
[versions]
apache-commons-csv = "1.8"
clikt = "5.0.1"
coroutines = "1.9.0"
dropwizard = "3.0.12"
google-libphonenumber = "8.13.52"
jackson = "2.18.2" # Use the same version as dropwizard
jetty = "10.0.24" # Use the same version as dropwizard
json-json = "20240205"
kotlinx-serialization = "1.6.3"
opencsv = "5.8"
# AWS
aws = "1.12.773"
kinesis = "0.15.11"
# grpc
armeria = "1.31.3"
grpc = "1.68.1" # Should match the version used in armeria to avoid problems
grpc-kotlin = "1.4.1"
protovalidate = "0.2.1"
protobuf = "3.25.5" # Should match the version used in armeria to avoid problems

# Testing
hamcrest = "3.0"
jersey-grizzly2 = "2.46"
mockk = "1.13.13"
shazamcrest = "0.11"
testcontainers = "1.20.2"

[libraries]
# apache commons
apache-commons-csv = { group = "org.apache.commons", name="commons-csv", version.ref = "apache-commons-csv" }
# armeria
armeria = { group = "com.linecorp.armeria", name="armeria", version.ref = "armeria" }
armeria-grpc = { group = "com.linecorp.armeria", name="armeria-grpc", version.ref = "armeria" }
armeria-kotlin = { group = "com.linecorp.armeria", name="armeria-kotlin", version.ref = "armeria" }
# AWS
amazon-kinesis-producer = { group = "com.amazonaws", name="amazon-kinesis-producer", version.ref = "kinesis" }
aws-java-sdk-bom = { group = "com.amazonaws", name="aws-java-sdk-bom", version.ref = "aws" }
aws-java-sdk-core = { group = "com.amazonaws", name="aws-java-sdk-core", version.ref = "aws" }
aws-java-sdk-kinesis = { group = "com.amazonaws", name="aws-java-sdk-kinesis", version.ref = "aws" }
aws-java-sdk-s3 = { group = "com.amazonaws", name="aws-java-sdk-s3", version.ref = "aws" }
aws-java-sdk-secretsmanager = { group = "com.amazonaws", name="aws-java-sdk-secretsmanager", version.ref = "aws" }
aws-java-sdk-ses = { group = "com.amazonaws", name="aws-java-sdk-ses", version.ref = "aws" }
clikt = { group = "com.github.ajalt.clikt", name = "clikt", version.ref = "clikt" }
# Coroutines
coroutines-core = { group = "org.jetbrains.kotlinx", name="kotlinx-coroutines-core", version.ref = "coroutines"}
coroutines-debug = { group = "org.jetbrains.kotlinx", name="kotlinx-coroutines-debug", version.ref = "coroutines"}
coroutines-slf4j = { group = "org.jetbrains.kotlinx", name="kotlinx-coroutines-slf4j", version.ref = "coroutines"}
google-libphonenumber = { group = "com.googlecode.libphonenumber", name="libphonenumber", version.ref = "google-libphonenumber"}
# Dropwizard
dropwizard-auth = { group = "io.dropwizard", name="dropwizard-auth", version.ref = "dropwizard"}
dropwizard-testing = { group = "io.dropwizard", name="dropwizard-testing", version.ref = "dropwizard"}
dropwizard-forms = { group = "io.dropwizard", name="dropwizard-forms", version.ref = "dropwizard"}
dropwizard-core = { group = "io.dropwizard", name="dropwizard-core", version.ref = "dropwizard"}
dropwizard-assets = { group = "io.dropwizard", name="dropwizard-assets", version.ref = "dropwizard"}
# gRPC
grpc-bom = { group = "io.grpc", name="grpc-bom", version.ref = "grpc" }
grpc-api = { group = "io.grpc", name="grpc-api", version.ref = "grpc" }
grpc-util = { group = "io.grpc", name="grpc-util", version.ref = "grpc" }
grpc-services = { group = "io.grpc", name="grpc-services", version.ref = "grpc" }
grpc-netty = { group = "io.grpc", name="grpc-netty", version.ref = "grpc" }
grpc-testing = { group = "io.grpc", name="grpc-testing", version.ref = "grpc" }
grpc-inprocess = { group = "io.grpc", name="grpc-inprocess", version.ref = "grpc" }
grpc-kotlin = { group = "io.grpc", name="grpc-kotlin-stub", version.ref = "grpc-kotlin" }
protovalidate = { group = "build.buf", name="protovalidate", version.ref = "protovalidate" }
protobuf-util = { group = "com.google.protobuf", name="protobuf-java-util", version.ref = "protobuf" }
protobuf = { group = "com.google.protobuf", name="protobuf-java", version.ref = "protobuf" }
# Jackson
jackson-core = { group = "com.fasterxml.jackson.module", name="jackson-module-kotlin", version.ref = "jackson"}
jackson-kotlin = { group = "com.fasterxml.jackson.module", name="jackson-module-kotlin", version.ref = "jackson"}
jackson-databind = { group = "com.fasterxml.jackson.core", name="jackson-databind", version.ref = "jackson"}
jackson-annotations = { group = "com.fasterxml.jackson.core", name="jackson-annotations", version.ref = "jackson"}
jackson-csv = { group = "com.fasterxml.jackson.dataformat", name="jackson-dataformat-csv", version.ref = "jackson"}
jackson-xml = { group = "com.fasterxml.jackson.dataformat", name="jackson-dataformat-xml", version.ref = "jackson"}
jackson-yaml = { group = "com.fasterxml.jackson.dataformat", name="jackson-dataformat-yaml", version.ref = "jackson"}
jackson-jsr310 = { group = "com.fasterxml.jackson.datatype", name="jackson-datatype-jsr310", version.ref = "jackson"}
# Jetty
jetty-server = { group = "org.eclipse.jetty", name="jetty-server", version.ref = "jetty"}
jetty-unixsocket = { group = "org.eclipse.jetty", name="jetty-unixsocket-server", version.ref = "jetty"}
jetty-util = { group = "org.eclipse.jetty", name="jetty-util", version.ref = "jetty"}
jetty-http2 = { group = "org.eclipse.jetty.http2", name="http2-server", version.ref = "jetty"}
json-json = { group = "org.json", name="json", version.ref = "json-json"}
# Kotlin
kotlinx-serialization-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-core", version.ref = "kotlinx-serialization"}
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization"}
opencsv = { group = "com.opencsv", name = "opencsv", version.ref = "opencsv"}
# Testing
coroutines-test = { group = "org.jetbrains.kotlinx", name="kotlinx-coroutines-test", version.ref = "coroutines"}
hamcrest = { group = "org.hamcrest", name="hamcrest", version.ref = "hamcrest"}
jersey-grizzly2 = { group = "org.glassfish.jersey.test-framework.providers", name="jersey-test-framework-provider-grizzly2", version.ref = "jersey-grizzly2"}
mockk = { group = "io.mockk", name = "mockk", version.ref = "mockk" }
shazamcrest = { group = "com.shazam", name="shazamcrest", version.ref = "shazamcrest"}
testcontainers-junit = { group = "org.testcontainers", name = "junit-jupiter", version.ref = "testcontainers" }
testcontainers = { group = "org.testcontainers", name = "testcontainers", version.ref = "testcontainers" }
I will double check but I think that we are using the catalog accessor in other modules without any problem
v
jackson-core = { group = "com.fasterxml.jackson.module", name="jackson-module-kotlin", version.ref = "jackson"}
Have a closer look 😉
r
ouch 😢
v
🙂
r
bad copy paste
thank you so much
👌 1
v
yep
r
I was working on a small reproducer but your eyes are better than mine 🙇
I reproduced the error, what is not supported is this:
Copy code
constraints {
        api(libs.jackson.core).because("Require at least the same version of the catalog")
    }
It fails with: "You shouldn't use a dependency constraint created via a Provider directly" but this construct works fine:
Copy code
constraints {
    api(libs.jackson.core) {
        because("Require at least the same version of the catalog")
    }
}
👌 1