Hi all, i'm getting a `Duplicate JVM class name` e...
# arrow
t
Hi all, i'm getting a
Duplicate JVM class name
error after moving to arrow 0.11.0 and Kotlin 1.4.10 when using optics. As far as I can tell this is similar to the issue @Joram Visser raised here except in my case I'm using gradle not maven. I'm struggling to debug this, because optics are compiling correctly elsewhere in the same project, and it just seems to be one data class that is now causing this error. I tried creating a new repo and reproducing but it compiles and run fine. Any suggestions on how to approach debugging this?
I can't post all of the code as it has too many dependencies on the rest of our project, but here's roughly the data class in question:
Copy code
package io.glimpseprotocol.vault.domain.state

import arrow.optics.optics
import io.glimpseprotocol.core.domain.vault.Mnemonic
import io.glimpseprotocol.core.infrastructure.IDocument
import io.glimpseprotocol.core.valueobject.Id
import io.glimpseprotocol.vault.domain.module.ModuleMeta
import io.glimpseprotocol.vault.domain.module.dataingest.DataIngestModule
import io.glimpseprotocol.vault.domain.module.export.ExportModule
import io.glimpseprotocol.vault.domain.module.ping.PingModule
import io.glimpseprotocol.vault.domain.module.prebid.PrebidModule
import java.time.Instant

typealias NextVaultState = State

@optics
data class State(
    override val _id: Id<State> = Id(),
    override val _created: Instant = Instant.now(),
    override val _updated: Instant = Instant.now(),
    override val _schema: Int = 1,
    val mnemonic: Mnemonic = Mnemonic(),
    val ping: ModuleMeta = PingModule.DefaultMeta,
    val data: ModuleMeta = DataIngestModule.DefaultMeta,
    val export: ModuleMeta = ExportModule.DefaultMeta,
    val identity: IdentityState = IdentityState(),
    val tether: List<TetherState> = emptyList(),
    val prebid: ModuleMeta = PrebidModule.DefaultMeta,
    val frequencyCapping: FrequencyCappingState = FrequencyCappingState()
) : IDocument<State> {
    override fun touch(): State =
        copy(_updated = Instant.now())

    companion object
}
Actually optics aren't compiling correctly elsewhere ... i'm getting some that fail and some that don't 😞 Also it looks like I can work around this by manually renaming the JvmClass name with
@file:JvmName("SomethingUnique")
as per https://stackoverflow.com/questions/57762986/how-to-configure-build-gradle-kts-to-fix-error-duplicate-jvm-class-name-generat ... maybe this is a kotlin issue?
j
I never got any further on this. The
@file:JvmName("SomethingUnique")
does work for my case as well. Thanks! 😄 That is already cleaner than copy pasting the generated code (which was my work around up until now).
r
Unfortunately Optics is the last piece of functionality we need to port to meta to be able to remove kapt and become MPP. If nobody addresses it we will as part of the arrow refactor. The processor still needs to be ported over.
👍 1
t
Thanks for the update. The JvmName file annotation is a striaghtfoward workaround so no rush from my perspective
178 Views