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

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.

主站蜘蛛池模板: 平遥县| 高安市| 宜都市| 慈溪市| 临湘市| 西平县| 林州市| 许昌县| 绩溪县| 元江| 宁波市| 黄大仙区| 田林县| 定远县| 云林县| 沂南县| 漠河县| 广东省| 中江县| 丰宁| 江川县| 常宁市| 青阳县| 毕节市| 枣庄市| 五原县| 阆中市| 门头沟区| 安化县| 雷山县| 蛟河市| 彰化县| 瓦房店市| 灌阳县| 建水县| 桃园市| 福清市| 肇州县| 朔州市| 沙河市| 凤庆县|