I am upgrading some projects to use 0.11.0, most t...
# arrow
j
I am upgrading some projects to use 0.11.0, most things are fine except for one project where I use optics. The data class annotated with @optics seems to fail my build due to duplicate JVM names. (The project actually works fine if I copy the generated optics into the project and remove the annotations.) I haven’t changed anything except for versions in the pom file, so I am not sure why this is happening. Any ideas how to resolve this?
The output during compilation:
Copy code
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.4.10:compile (compile) on project ..: Compilation failure: Compilation failure: 
[ERROR] /../../../../src/main/kotlin/../../../model/MyModel.kt:[17,1] Duplicate JVM class name '../../../model/MyModelKt' generated from: package-fragment .........model, package-fragment .........model
[ERROR] /../../../../target/generated-sources/kapt/compile/../../../model/MyModel.kt:[1,1] Duplicate JVM class name '../../../model/MyModelKt' generated from: package-fragment .........model, package-fragment .........model
a
Hi @Joram Visser thank you for posting, would you kindly create an issue in the optics repo? Otherwise I can create it tomorrow 🙂 https://github.com/arrow-kt/arrow-optics
r
Hi @Joram Visser, there is just an issue so far if the
package
is missing (it's necessary now). Could it be possible to review it? Or part of the code to try to reproduce it. I don't understand why those paths appear in that way. And I see Kotlin 1.4.10. Could you try it with Kotlin 1.4.0?
@aballano 🙌
At the same time 😅
1
Another idea @Joram Visser: did you run the Gradle
clean
task before building the project again?
j
Thanks for the fast responses. I was actually hoping that the usage of optics slightly had changed and that I needed to make some minor changes to make it work with 0.11.0. But it seems like this is unexpected for you two as well. I’ll try to make a small project to reproduce this issue. That may also narrow down the problem I am facing. I hope I have some time for it tonight.
🔝 1
r
Awesome, thanks to you @Joram Visser🙌
j
See: https://github.com/joramnv/optics When I run
mvn clean package
the result is:
Copy code
[ERROR] Failed to execute goal org.jetbrains.kotlin:kotlin-maven-plugin:1.4.0:compile (compile) on project optics: Compilation failure: Compilation failure: 
[ERROR] /Users/joram/projects/optics/src/main/kotlin/com/joram/optics/model/MyModel.kt:[1,1] Duplicate JVM class name 'com/joram/optics/model/MyModelKt' generated from: package-fragment com.joram.optics.model, package-fragment com.joram.optics.model
[ERROR] /Users/joram/projects/optics/target/generated-sources/kapt/compile/com/joram/optics/model/MyModel.kt:[1,1] Duplicate JVM class name 'com/joram/optics/model/MyModelKt' generated from: package-fragment com.joram.optics.model, package-fragment com.joram.optics.model
👍 1
🙌 1
r
Hi @Joram Visser, thank you so much for preparing this project to review your error 👏 It seems it's necessary to configure the use of
package
goal because
mvn org.jetbrains.kotlin:kotlin-maven-plugin:1.4.0:compile
(the goal that fails when running
package
) doesn't raise any error and the content of
target
directory is right. Then
mvn org.apache.maven.plugins:maven-jar-plugin:2.4.jar
creates the JAR with all the content and it doesn't raise any error either. BTW, the generated source code isn't Kotlin code but Java. I also tried your source code with Gradle and the package is generated without errors. Please, let us know if you make it work when tuning
package
. Thanks again!! 🙌