官术网_书友最值得收藏!

Using the all-open plugin in Gradle

The all-open plugin for Gradle can be used as follows:

buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
}
}
apply plugin: "kotlin-allopen"

We have to add the plugin artifact in the buildscript dependencies section of the Gradle file. We can also enable the all-open plugin using the plugins section, as follows:

plugins {
id "org.jetbrains.kotlin.plugin.allopen" version "1.2.41"
}

Following this, we can specify a list of annotations that will make our classes open and accessible:

allOpen {
annotation("javax.ejb.Stateless")
}

We can specify multiple annotations using the annotations section in the allOpen plugin:

 allOpen {
annotations("javax.ejb.Stateless",
"javax.inject.Inject")
}

We can then define custom annotations. The all-open compiler plugin is used to open the classes that are annotated with the custom annotations:

allOpen {
annotation("org.rao.kotlin.javaee.Annotation")
}


@org.rao.kolin.javaee.Annotation
annotation class MyAnnotation

@MyAnnotation
class Person{ }

Now, the Person class will be open.

The MyAnnotation class is annotated with a meta-annotation—@org.rao.kolin.javaee.Annotation. It is now an all-open plugin annotation that can be used in other classes to make them open and accessible.

主站蜘蛛池模板: 定安县| 伊春市| 仁布县| 安吉县| 赞皇县| 丰原市| 沙田区| 永登县| 灵山县| 灌云县| 新乐市| 沾益县| 仙游县| 五河县| 武强县| 连平县| 阜平县| 三穗县| 长兴县| 奉贤区| 临洮县| 丹巴县| 分宜县| 隆尧县| 嘉禾县| 深泽县| 图片| 巢湖市| 金乡县| 大竹县| 黔南| 临猗县| 巴中市| 天门市| 龙泉市| 安平县| 普安县| 靖西县| 溧水县| 镇原县| 宝兴县|