NavX library doesn't compile

I am working on a Kotlin library for my team, and I split it into multiple artifacts (based on vendors) so if we use only products from not all the vendors, we wouldn’t need to depend on everything. I include the library from maven via jitpack. However, the artifact based on the Kauai library fails each time I run, thus all following artifacts aren’t built. I have tried including the Kauai library in multiple ways, including the way libraries are included in robot code projects (wpi.deps.vendor.java()), and the basic gradle way (manually adding the repository and dependency artifact).

The error/stack trace in the jitpack log:
* What went wrong:
Execution failed for task ':kauai:compileKotlin'.
> Could not resolve all files for configuration ':kauai:compileClasspath'.
   > Could not resolve com.kauailabs.navx.frc:navx-java:3.1.413.
 Required by:
     project :kauai
  > Unable to find a matching variant of com.kauailabs.navx.frc:navx-java:3.1.413:
      - Variant 'apiElements' capability com.kauailabs.navx.frc:navx-java:3.1.413:
          - Incompatible attribute:
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
          - Other attributes:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.libraryelements 'classes' and found compatible value 'jar'.
              - Found org.gradle.status 'release' but wasn't required.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-api'.
              - Required org.jetbrains.kotlin.platform.type 'jvm' but no value provided.
      - Variant 'runtimeElements' capability com.kauailabs.navx.frc:navx-java:3.1.413:
          - Incompatible attribute:
              - Required org.gradle.jvm.version '8' and found incompatible value '11'.
          - Other attributes:
              - Found org.gradle.category 'library' but wasn't required.
              - Required org.gradle.dependency.bundling 'external' and found compatible value 'external'.
              - Required org.gradle.libraryelements 'classes' and found compatible value 'jar'.
              - Found org.gradle.status 'release' but wasn't required.
              - Required org.gradle.usage 'java-api' and found compatible value 'java-runtime'.
              - Required org.jetbrains.kotlin.platform.type 'jvm' but no value provided.

What I do as a workaround is unlink the artifact and build everything else, then relink it. However, it’s a very inconvenient method.
My main theory for the reason it is failing is that the Kauai lib is Java 11, and Kotlin compiles into Java 8 bytecode, and that causes the error. Is there a way to fix this?
The library repo is here.

1 Like

Are you sure that you’re building with JDK 11? You can verify by running ./gradlew --version:

------------------------------------------------------------
Gradle 6.1
------------------------------------------------------------

Build time:   2020-01-15 23:56:46 UTC
Revision:     539d277fdba571ebcc9617a34329c83d7d2b259e

Kotlin:       1.3.61
Groovy:       2.5.8
Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
JVM:          11.0.1 (Oracle Corporation 11.0.1+13)
OS:           Windows 10 10.0 amd64

I was able to clone your library and successfully run ./gradlew build without any of the errors you mentioned above.

Edit: I attempted to build your project using JDK 8 and ran into the same error that you described.

Based on the log at https://jitpack.io/com/github/Starlight220/XcaLib/1.0.0/build.log, JitPack used Java 8 to build your project by default.

There are instructions at https://jitpack.io/docs/BUILDING/ (under section “java version”) on how to change the java version.

Basically you need to add this to jitpack.yml at the repo root:

jdk:
  - openjdk11
1 Like

Thanks for informing of a tangible/easy way to fix this. Thanks @Prateek_M for the analysis. It’s my first time working with jitpack… It’s also my first time using CI/CD other than contributing to allwpilib (if you count either of those as CI/CD). Are there any good resources to learn CI/CD tools from? I don’t count git, as I use it regularly.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.