- Kotlin for Enterprise Applications using Java EE
- Raghavendra Rao K
- 184字
- 2021-06-10 18:49:29
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.
- 數據庫程序員面試筆試真題與解析
- Angular UI Development with PrimeNG
- TypeScript Blueprints
- Java應用開發與實踐
- Swift 3 New Features
- Implementing Cisco Networking Solutions
- 單片機應用技術
- 快人一步:系統性能提高之道
- PySide 6/PyQt 6快速開發與實戰
- 基于SpringBoot實現:Java分布式中間件開發入門與實戰
- Learning Modular Java Programming
- Visual Studio Code 權威指南
- Python預測分析與機器學習
- Python Social Media Analytics
- MySQL數據庫應用實戰教程(慕課版)