Sadly Realm 1.16.0 does not support Kotlin 2.0.0. ...
# realm
z
Sadly Realm 1.16.0 does not support Kotlin 2.0.0. https://github.com/realm/realm-kotlin/issues/1614 Any chance this will happen any time soon?
k
y
n
📣 We just released a snapshot release (
2.0.0-SNAPSHOT
) with support of
K2
compiler. Please give it a try and report any issue before we include this into the next major release. Here’s a sample app using it https://github.com/realm/realm-kotlin-samples/pull/48
👍 1
K 3
j
Maybe mixed up something but should that be still available there? I think
<https://oss.sonatype.org/content/repositories/snapshots>
is correct repository for that snapshot?
Copy code
Plugin [id: 'io.realm.kotlin', version: '2.0.0-SNAPSHOT'] was not found in any of the following sources:

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at <https://help.gradle.org>.

* Exception is:
org.gradle.api.plugins.UnknownPluginException: Plugin [id: 'io.realm.kotlin', version: '2.0.0-SNAPSHOT'] was not found in any of the following sources:

- Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (could not resolve plugin artifact 'io.realm.kotlin:io.realm.kotlin.gradle.plugin:2.0.0-SNAPSHOT')
  Searched in the following repositories:
    Google
    MavenRepo
    Gradle Central Plugin Repository
    maven(<https://oss.sonatype.org/content/repositories/snapshots>)
c
The marker plugin (that allows applying from an
id(...)
) is not published to the snapshot repository. So you would have to reference the actual maven coordinates directly. Easiest thing is to add it to the classpath in the project level Gradle file as It's done here and then you can apply it by
id("io.realm.kotlin")
in the subprojects.
j
thanks, I'll try that
hmm, I'm probably missing something basic with gradle but have following in my
settings.gradle.kts
and still seeing that ...I also tried putting that in root
build.gradle.kts
but didn't help
Copy code
rootProject.name = "BikeShare"
enableFeaturePreview("TYPESAFE_PROJECT_ACCESSORS")

pluginManagement {
    repositories {
        google {
            mavenContent {
                includeGroupAndSubgroups("androidx")
                includeGroupAndSubgroups("com.android")
                includeGroupAndSubgroups("com.google")
            }
        }
        mavenCentral()
        gradlePluginPortal()
        maven("<https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental>")
        maven("<https://oss.sonatype.org/content/repositories/snapshots>")

    }
}

dependencyResolutionManagement {
    repositories {
        google {
            mavenContent {
                includeGroupAndSubgroups("androidx")
                includeGroupAndSubgroups("com.android")
                includeGroupAndSubgroups("com.google")
            }
        }
        mavenCentral()
        maven("<https://maven.pkg.jetbrains.space/kotlin/p/wasm/experimental>")
        maven("<https://oss.sonatype.org/content/repositories/snapshots>")

    }
}

buildscript {
    dependencies {
        classpath("io.realm.kotlin:gradle-plugin:2.0.0-SNAPSHOT")
    }
}


include(":androidApp")
include(":common")
include(":compose-desktop")
include(":compose-web")
(this is different btw to what's in the BikeShare repo right now as I'm in process of trying to make gradle setup more consistent across the samples)
y
works for me like that: root/build.gradle.kts
Copy code
buildscript {
    dependencies {
        classpath("io.realm.kotlin:gradle-plugin:2.0.0-SNAPSHOT")
    }
}
module/build.gradle.kts
Copy code
plugins {
  id("io.realm.kotlin")
}

...

configurations.all {
    resolutionStrategy.cacheChangingModulesFor(0,TimeUnit.SECONDS)
}
settings.gradle.kts
Copy code
pluginManagement {
    repositories {
        google()
        gradlePluginPortal()
        mavenCentral()
        maven {
            url = uri("<https://oss.sonatype.org/content/repositories/snapshots>")
        }
    }
}

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven {
            url = uri("<https://oss.sonatype.org/content/repositories/snapshots>")
        }
    }
}
c
Hmm. Are you using version catlogs? It might be because it somehow resolves the plugin differently through the providers from that. Had to apply it from id with the plain id in our samples as seen here
j
yes, using version catalogs
yeah, using
id("io.realm.kotlin")
instead of
alias(libs.plugins.realm.kotlin)
seems to make a difference all right
G 1
issue now is that adding following is causing other issues for project e.g.
The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found
Copy code
buildscript {
    dependencies {
        classpath("io.realm.kotlin:gradle-plugin:2.0.0-SNAPSHOT")
    }
}
c
Hmm. Haven't seen that before. Most of our samples also use Compose, so don't really know where to point from that 🤔
j
Is there sample atm that uses that snapshot?
c
Yes. There's a pull request here that updates all our samples to the snapshot.
👍 1
j
thanks, have that running here so will compare with what I have
👍 1
still having same issue.....I pushed my changes to following branch just in case you can take a quick a look at some point in case anything jumps out https://github.com/joreilly/BikeShare/tree/dependency_upddates
z
Mixing buildSrc and version catalog can cause similar issues, not sure if this exactly. It might be worth finally removing buildSrc.
I was able to get Realm working with the snapshot
j
Ah, forgot about that.....yeah, intending to remove that very soon
Removed
buildSrc
but still seeing same issue (updated branch with changes)....it's not helping that I'm changing other things at the same time so could very likely be related to those changes as well.....I'll see if I can get it working with existing stable version of realm (not sure though if that's possible using Kotlin 2.0)
yeah, looks like something I messed up in migration....still narrowing it down but nothing to do with realm....sorry for confuision
👍 1
c
Setting up compose seems to have changed a bit in K2. If it is still the
The Compose Compiler requires the Compose Runtime to be on the class path, but none could be found
Have you both applied the
org.jetbrains.compose
and the
org.jetbrains.kotlin.plugin.compose
plugin?
j
Yeah, got it resolved, thanks
it was due to some unnecessary stuff I had brought over from a different project that I'd updated to Kotlin 2
👍 1
BikeShare repo updated now with the changes
🎉 2
b
Just wondering, https://github.com/realm/realm-java will have similar issues with k2?
157 Views