Gradle 不能有抽象方法

art*_*002 3 java gradle gradle-plugin

我正在开发一个自定义二进制 Gradle 插件,遵循此处所示的模式。

我的扩展 VersionInfoExtension 是抽象的,带有抽象方法,就像文档中的 BinaryRepositoryExtension 一样。我的任务也是抽象的,参数采用抽象方法,例如文档中的LatestArtifactVersion。当我测试时,我收到以下错误:

An exception occurred applying plugin request [id: 'com.example.version-info']
> Failed to apply plugin 'com.example.version-info'.
   > Could not create an instance of type com.example.gradle.version.VersionInfoExtension.
      > Could not generate a decorated class for type VersionInfoExtension.
         > Cannot have abstract method VersionInfoExtension.jars().
Run Code Online (Sandbox Code Playgroud)

我缺少什么?有没有什么好的例子可以让这项工作发挥作用?

Ric*_*tze 9

我正在使用 gradle 7.X 和 Kotlin。

当方法名带有以下前缀时,会报“Cannot have abstract method myPropertyName”错误"is"

abstract val isRegistered: Property<Boolean>
Run Code Online (Sandbox Code Playgroud)

追踪起来很烦人。类型似乎并不重要。

"is"解决方案是从名称中删除。