Records需要ASM8

huangapple go评论78阅读模式
英文:

Records requires ASM8

问题

我想尝试一下具有预览功能的最新Java 15。我正在使用支持Java 15功能的Spring Boot 2.4.0-M2和Gradle 6.7-rc2。我想使用jib从我的项目构建一个Docker镜像。这是我的jib配置:

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

不幸的是,当我运行./gradlew jib时,我收到以下错误:

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

以下是使用--info标志运行时的输出:

> 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.

是否有人遇到过类似的问题?

英文:

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 = &#39;openjdk:15-jdk&#39;
	}	
	to {
		image = &#39;&lt;username&gt;/&lt;project&gt;&#39;
	}
	container {
		jvmFlags = [&#39;--enable-preview&#39;]
	}
}

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

Execution failed for task &#39;:jib&#39;.
&gt; Records requires ASM8

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

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

Have anyone had a similar problem?

答案1

得分: 8

如果您在使用 Android 并且正在使用 Moshi 1.13.0 和 Dagger Hilt,需要将以下内容添加到您应用程序根目录下的 gradle.properties 文件中。

 android.jetifier.ignorelist=moshi-1.13.0

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

英文:

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

答案2

得分: 1

ASM在内部机制中有一个应用程序必须通过代码选择要使用的API级别。这意味着仅仅更新依赖关系在这种情况下是无效的。

长期的解决方案将是等待jib切换到更新的API级别。

但是,这个Github评论表明,当您明确指定主类时,不需要ASM。

因此,您可以通过指定主类来避免使用“旧的”ASM API级别(正如您的日志中所述,这还将加速jib构建步骤)。

英文:

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).

答案3

得分: 1

关于错误信息“在 'jar' 任务中找不到有效的主类”,这个任务缺少主类。因此,您必须添加主类,进程应该可以正常工作:

mainClassName = "your.MainClass"
英文:

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

mainClassName = &quot;your.MainClass&quot;

huangapple
  • 本文由 发表于 2020年9月27日 18:14:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/64087297.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定