HI folks. I’m trying to install a 3rd party Kotli...
# getting-started
l
HI folks. I’m trying to install a 3rd party Kotlin package, not on mavenCentral. It’s an OpenSearch client. The install instructions are here: https://jillesvangurp.github.io/kt-search/manual/GettingStarted.html When I add that to my Gradle file, however, I get an error that the package cannot be found. I… do not know how to even start debugging this. 😬 Any pointers?
p
Can you prepare a minimal open-source reproducer?
l
Could take a bit… I’m literally just adding those ~6 lines to a gradle file.
Ah, just confirmed in a brand new project. Same behavior.
Wait… Ugh. It works if I specify a precise version number directly. 😞
How can I figure out which versions of a package are compatible with a particular Kotlin version?
m
Can you paste the non-working and working version to see the difference?
l
This downloads and compiles:
Copy code
implementation("com.jillesvangurp:search-client:2.2.1")
This does not:
Copy code
implementation("com.jillesvangurp:search-client")
Problem is, 2.2.1 requires Kotlin 1.9, and my project is on 1.7 at the moment. (Yes, we need to fix that.) I don’t know how to figure out what older version of the project will be compatible with 1.7, if any.
m
It has nothing to do with Kotlin version. Just by reading the Readme of this package there's precisely written, that you need to provide the version. You can skip version only if you use a dependency manager like for instance is provided by Spring Boot, but you won't find there so indie packages like this one. If it compiles, where's the issue?
l
My colleague was getting errors when he tried to run a sample script. I’m trying to retrace his steps. Hang on, let me try and isolate.
👍 1
Ah here we are. When we try to build/run a test script, we get this error:
Class 'com.jillesvangurp.ktsearch.SearchClient' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.9.0, expected version is 1.7.1.
So Gradle will happily download it, but I guess it doesn’t compile after all.
m
Okay, I never faced this kind of error... I guess in that situation you would need to fork the library and compile it in Kotlin 1.7, or ask the author if there was any old version compiled in 1.7
l
There’s no way to find out other than guess-and-check or emailing the author?
m
You can try checking the history of build.gradle files in the repository, like 2 years ago
l
🤔
m
Eventually there's Kotlin dependency with version specified somewhere, so you'd need to find the release for the moment the version was 1.7
l
Ah ha, I found the moment in the git log where the kotlinVersion line changed in the gradle file. 😬
Found an older version that is 1.7 compatible. And… it depends on a library that is not 1.7 compatible in the version it specifies.
💩