3

I am trying to use kotlinx.serialization and have had just no luck. Here is the pertinent portion of the build.gradle

buildscript {
    ext.kotlin_version = '1.3.71'

    repositories {
        mavenCentral()
        google()
        jcenter()
        maven("https://kotlin.bintray.com/kotlinx")
    }
    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
    }
}

This dies on the vine:

Could not find method maven() for arguments [https://kotlin.bintray.com/kotlinx] 
on repository container of type org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler

enter image description here

What is an up-to-date way to incorporate kotlinx-serialization ?

WestCoastProjects
  • 58,982
  • 91
  • 316
  • 560

2 Answers2

2

The arguments of method maven in org.gradle.api.internal.artifacts.dsl.DefaultRepositoryHandler is Closure,and the context object is type org.gradle.api.artifacts.repositories.MavenArtifactRepository,so the correct script would be like

repositories {
   mavenCentral()
   maven {
    url="https://kotlin.bintray.com/kotlinx"
  }

} what's more,kotlinx.serialization exists in mavencentral,so there is no need to add your custom maven repository

neo
  • 604
  • 3
  • 10
  • The `bintray` url was added as one of a number of attempts to find the thing.. – WestCoastProjects Apr 08 '20 at 04:26
  • I guess he/she's using build.gradle.kts, not build.gradle. I have similar constructs in perfectly valid projects – user3159253 Apr 08 '20 at 04:28
  • @user3159253 what's your gradle version – neo Apr 08 '20 at 04:30
  • Your points are valid (and I upvoted). Turns out the `kotlinx` version is one minor-minor tick behind and @user3159253 found that: I asked him to create an answer. – WestCoastProjects Apr 08 '20 at 04:34
  • I"m excited about `kotlin`. I'm a team-lead level scala developer as my main language for five years until `python` last year. Dislike python for anything but a wrapper for the great `numpy` and friends libraries. Language itself is quite weak. `kotlin` gives 90% of value of `scala` but is more approachable so I can try to use it in scenarios with java folks. – WestCoastProjects Apr 08 '20 at 04:36
  • @neo we've switched to 6.3, but the code of the buildsystem hasn't been changed since 5.x, at least since mid-2019 – user3159253 Apr 08 '20 at 04:40
  • @javadba actually I used to be a python guy, but all my recent projects are kotlin ones ;-) – user3159253 Apr 08 '20 at 04:46
  • 1
    doing `kotlin` you'll understand a bit of where i'm coming from. `for comprehensions` solve 20% of the collections processing problems. We're left to our own devices for the rest. Oh and don't even get me started about multithreading. – WestCoastProjects Apr 08 '20 at 04:49
2

It looks like the actual version for kotlinx.serialization is 1.3.70, not 1.3.71 At least their master branch depends on 1.3.70 kotlin components

user3159253
  • 16,836
  • 3
  • 30
  • 56