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

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.

主站蜘蛛池模板: 剑川县| 彰武县| 崇仁县| 仁化县| 湘阴县| 巧家县| 迁安市| 桂东县| 客服| 弥勒县| 朝阳市| 钦州市| 香格里拉县| 黄浦区| 黔江区| 桐梓县| 玛曲县| 社会| 积石山| 梅河口市| 固安县| 左权县| 安阳市| 沭阳县| 东乌珠穆沁旗| 武平县| 阳谷县| 景德镇市| 来宾市| 资兴市| 利辛县| 虎林市| 昌吉市| 西宁市| 大悟县| 军事| 南部县| 上饶县| 阿城市| 武鸣县| 昌黎县|