Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle Cannot have abstract method

I'm developing a custom binary Gradle plugin, following the pattern shown here.

My extension, VersionInfoExtension is abstract with abstract methods, just like the BinaryRepositoryExtension in the documentation. My task is also abstract, with abstract methods for the parameters, like the LatestArtifactVersion in the documentation. When I test, I get the following error:

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

What am I missing? Are there any good examples of making this work?

like image 639
artk2002 Avatar asked Aug 31 '25 04:08

artk2002


1 Answers

I'm using gradle 7.X and Kotlin.

The "Cannot have abstract method myPropertyName" error is reported when the method name is prefixed by "is":

abstract val isRegistered: Property<Boolean>

That was annoying to track down. The type doesn't seem to matter.

The solution was to remove "is" from the name.

like image 65
Richard Sitze Avatar answered Sep 02 '25 20:09

Richard Sitze