Records requires ASM8

6.1k views Asked by At

I want to play around with the newest Java 15 with preview features. I'm using Spring Boot 2.4.0-M2 and Gradle 6.7-rc2, where both of them support Java 15 features.
I want to build a docker image from my project using jib. Here's my jib configuration:

jib {
    from {
        image = 'openjdk:15-jdk'
    }   
    to {
        image = '<username>/<project>'
    }
    container {
        jvmFlags = ['--enable-preview']
    }
}

Unfortunately, when I'm running ./gradlew jib I'm getting the following error:

Execution failed for task ':jib'.
> Records requires ASM8

And here's the output while running with --info flag:

> Task :jib FAILED
Caching disabled for task ':jib' because:
  Build cache is disabled
Task ':jib' is not up-to-date because:
  Task has not declared any outputs despite executing actions.
Searching for main class... Add a 'mainClass' configuration to 'jib' to improve build speed.
Could not find a valid main class from 'jar' task; looking into all class files to infer main class.
:jib (Thread[Execution worker for ':',5,main]) completed. Took 0.003 secs.

Have anyone had a similar problem?

3

There are 3 answers

0
flaxel On BEST ANSWER

Regarding to the error message Could not find a valid main class from 'jar' task the main class is missing for this task. So you must add the main class and the process should work:

mainClassName = "your.MainClass"
1
Joachim Sauer On

ASM has an internal mechanism where the application has to select the API level to use via code. That means simply updating the dependency won't help in this case.

The long-term solution for this will be to wait for jib to switch to the newer API level.

But this Github comment suggests that ASM isn't needed when you specify the main class explicitly.

So you can get around the "old" ASM API level by specifying your main classit should also speed up the jib build step, as noted in your log).

0
georgiecasey On

If you're getting this on Android and you're using Moshi 1.13.0 and Dagger Hilt, add this to your gradle.properties file in the root of your app.

 android.jetifier.ignorelist=moshi-1.13.0

https://github.com/square/moshi/issues/1463#issuecomment-994576201