https://kotlinlang.org logo
#squarelibraries
Title
# squarelibraries
j

Javier

12/01/2023, 11:29 PM
Why is it mandatory to use Java 17 with 2.0.1?
h

hfhbd

12/02/2023, 2:03 AM
Because we use IntelliJ as compiler platform which requires JVM 17 since 2022.2. we do try to not pass these requirements to you as consumer, see https://github.com/cashapp/sqldelight/pull/4863, bit it’s not merged yet.
👍 1
j

Javier

12/02/2023, 8:59 AM
Will there be a quick version including it? I have seen the tests of that PR are not compiling due Java 17 too, so maybe it is not straightforward to fix it.
h

hfhbd

12/02/2023, 9:04 AM
Yeah, I aware of the failings, but didn’t take a closer look yet.
j

Javier

12/02/2023, 9:07 AM
I have checked and indeed my problem is inside the convention plugin:
Copy code
Execution failed for task ':hubdle-gradle-plugin:compileKotlin'.
> Could not resolve all files for configuration ':hubdle-gradle-plugin:compileClasspath'.
   > Could not resolve app.cash.sqldelight:gradle-plugin:2.0.1.
     Required by:
         project :hubdle-gradle-plugin > app.cash.sqldelight:app.cash.sqldelight.gradle.plugin:2.0.1
Would your change affect to the Sqldelight Gradle plugin too?
Ah yeah, it is being changed the Gradle plugin config. Sorry I was on mobile and I wasn't able to check it properly
h

hfhbd

12/02/2023, 9:10 AM
The idea of the PR is to run the sqldelight compiler in a separate JVM so you don’t need to use JVM 17 to consume the gradle plugin.
👍 1
thank you color 1
m

mbonnin

12/02/2023, 6:43 PM
How big of an issue is it? IIRC, Android, Spring Boot and apparently IntelliJ are 17+ now so hopefully the ecosystem should move quite fast?
1
j

Javier

12/02/2023, 6:46 PM
Which version of AGP is forcing that? I am on the latest stable and it compiles with 11
h

hfhbd

12/02/2023, 6:46 PM
AGP 8 requires JVM 17.
j

Javier

12/02/2023, 6:47 PM
That is weird, I will recheck but I have tests passing and I don’t remember touching anything when Renovate created the PRs
j

Javier

12/02/2023, 7:03 PM
Looks like it needs only Java 11 based on the message when trying to compile with Java 8
Copy code
> No matching variant of com.android.tools.build:gradle:8.2.0 was found. The consumer was configured to find a library for use during compile-time, compatible with Java 8, preferably in the form of class files, preferably optimized for standard JVMs, and its dependencies declared externally but:
          - Variant 'apiElements' capability com.android.tools.build:gradle:8.2.0 declares a library for use during compile-time, packaged as a jar, preferably optimized for standard JVMs, and its dependencies declared externally:
              - Incompatible because this component declares a component, compatible with Java 11 and the consumer needed a component, compatible with Java 8
h

hfhbd

12/02/2023, 7:04 PM
Can you try gradle-api?
j

Javier

12/02/2023, 7:05 PM
Same, Java 11
h

hfhbd

12/02/2023, 7:09 PM
Interesting 🤔
m

mbonnin

12/02/2023, 7:09 PM
Maybe the bytecode is Java11 with some runtime dependencies on 17. Running on Java 11 locally yields this:
Copy code
$ ./gradlew assembleDebug

FAILURE: Build failed with an exception.

* Where:
Build file '/Users/mbonnin/git/MyApplication3/app/build.gradle.kts' line: 1

* What went wrong:
An exception occurred applying plugin request [id: 'com.android.application', version: '8.3.0-alpha16']
> Failed to apply plugin 'com.android.internal.application'.
   > Android Gradle plugin requires Java 17 to run. You are currently using Java 11.
      Your current JDK is located in /Library/Java/JavaVirtualMachines/zulu-11.jdk/Contents/Home
      You can try some of the following options:
       - changing the IDE settings.
       - changing the JAVA_HOME environment variable.
       - changing `org.gradle.java.home` in `gradle.properties`.
(same with 8.2.0)
j

Javier

12/02/2023, 7:10 PM
That is different, I am not applying the plugin, I am only depending on it.
👍 1
m

mbonnin

12/02/2023, 7:10 PM
yes
But if you depend on it, chances are at some point someone will run the AGP code (alongside yours)
So you can compile against AGP with Java11 but you need Java17 to run it looks like
Looks like it's also because of IDEA requiring 17
j

Javier

12/02/2023, 7:14 PM
Yep, I am using Java 17 to build, but the source compatibility is Java 11. With Sqldelight the source compatibility is 17. Personally based on the timing, I would bet that requiring Java 17 on AGP was after discovering Java 17 compiles faster than Java 8/11.
👍 1
Anyway, I would think the equivalent use case would be requiring Java 17 to run the IDE plugin or applying the Sqldelight Gradle plugin but not requiring the source compatibility to Java 17.
Spring Boot requires Java 17 in source compatibility too?
m

mbonnin

12/02/2023, 7:19 PM
Yay, I would say source compatibility for the spring boot runtime (blog post)
Doesn't say about the gradle plugin so maybe you can still build your app with Java 11 🙂
Anyways, I'm usually a big fan of "keep things compatible as much as possible" but in that case, I'd say Java 17 is acceptable these days
Especially if the alternative requires downloading a JVM and forking a process
j

Javier

12/02/2023, 7:24 PM
Yeah, tbh I would use the latest, but as it is a convention plugin, I keep the minimum possible value as default. I was thinking moving to Java 21 on my machines next week as Gradle 8.5 was released 🎉
🚀 1
2 Views