The place where random ideas get written down and lost in time.
2024-04-28 - Conductor and Java 1.8 vs Java 11
Category DEVA few months ago I updated the Conductor project to new libraries, notably switching to Kotlin DSL 1.9. That made building with Java 11 a requirement.
In turn, that broke the way the Kotlin DSL is loaded under JMRI. I’m not sure why.
So fine, I reverted the Gradle files to a “Java 1_8” compatibility mode, and reverted to the older Kotlin DSL 1.6. This works fine when building the fat JAR, but it fails when trying to run the tests. It works fine when I actually build with a Java 1.8 JDK instead.
When building with Java 11 and running the tests, I get this cryptic gradle error: “Incompatible because this component declares an API of a component and the consumer needed a runtime of a component”
To be clear, the “build” part works. I get the fatJAR just fine. It’s the testing that fails, and only when doing it from Gradle on the command line. In IJ, I get the same behavior by selecting Conductor > All Tests on the root project.
I should try to replicate it with the gradle --info flag to see if that gives me more details on what is really breaking.
Another limitation is that only LibUtils v2 works with Java 1.8. LibUtils v3 already has Mockito dependencies that require Java 11.
But that seems all academic anyway. What I really want is to build with a Java 11 compatibility target since at this point even JMRI requires 11.
Then once I get that working, I need to retry with Kotlin DSL 1.9.
One thing for sure is from now on, when updating, I need to account for these scenarios:
- Testing does not work the same way under IJ or under command-line Gradle.
- Kotlin DSL loading does not work the same in standalone (simulator) vs from JMRI.