Kotlin-dsl-samples: kotlin-dsl script compilation and plugin apply the all-open kotlin compiler plugin for Gradle types

Created on 8 Jun 2017  Â·  9Comments  Â·  Source: gradle/kotlin-dsl-samples

all-open Gradle types (Task..)

feature help wanted kotlin-dsl-plugins ease-of-use groovy-parity plugin-support dropped

Most helpful comment

@eskatos
I tried out the allopen compiler plugin and it works as advertised.

It's a much nicer experience than forgetting to tag the task and the plugin as open and getting an error Cannot create a proxy class for final class at runtime.

All what is needed is to add an annotation to gradle/gradle and I would really like that this happens before Gradle reaches 5.0!

Demo here
https://github.com/jmfayard/gradledemo/commit/34e3bc66ffcff05189464e469bc6e503162b4abc

All 9 comments

The allopen kotlin compiler plugin only allows to use annotations to tag types. See https://kotlinlang.org/docs/reference/compiler-plugins.html

We'll either need to add such an annotation to the Gradle API and targeted types, or, praise for adding support for either listing open types in the allopen kotlin compiler plugin configuration or a custom matching mechanism (e.g. all subtypes of DefaultTask).

More infos about allopen:

If the class (or any of its superclasses) is annotated with com.your.Annotation, the class itself and all its members will become open. It even works with meta-annotations:

https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/opening-classes-for-frameworks.md

https://blog.jetbrains.com/kotlin/2016/12/kotlin-1-0-6-is-here/

@eskatos
I tried out the allopen compiler plugin and it works as advertised.

It's a much nicer experience than forgetting to tag the task and the plugin as open and getting an error Cannot create a proxy class for final class at runtime.

All what is needed is to add an annotation to gradle/gradle and I would really like that this happens before Gradle reaches 5.0!

Demo here
https://github.com/jmfayard/gradledemo/commit/34e3bc66ffcff05189464e469bc6e503162b4abc

@jmfayard, it looks great!
It's already too late for 5.0. It's now tentatively scheduled for 5.1.

Ok thanks Paul !

On Tue, Nov 6, 2018, 10:52 AM Paul Merlin notifications@github.com wrote:

@jmfayard https://github.com/jmfayard, it looks great!
It's already too late for 5.0. It's now tentatively scheduled for 5.1.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/gradle/kotlin-dsl/issues/390#issuecomment-436193928,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAcCyMEr_iehiwEsk_3JW4G8y871QAf1ks5usVvJgaJpZM4N0JeR
.

As an alternative, why doesn't Gradle create proxy classes for final classes similar to how ByteBuddy does for Mockito?

@mkobit I think that that's considered a pretty expensive operation. I'm guessing there are other reasons as well.

A prototype of allopen integration is available in the eskatos/compilation/allopen branch. It's not satisfactory yet in that the compiler plugins api for embedded compiler usage are only available in the maven plugin artifact.

Also see the discussion in https://github.com/gradle/gradle/pull/7971

Was this page helpful?
0 / 5 - 0 ratings