Reputation: 7497
Is it possible to convert a package level Java annotation to Kotlin?
Java annotation (MyAnnotation.java):
package com.myexample.annotation;
@Retention(RUNTIME) @Target(PACKAGE)
public @interface MyAnnotation {
}
Application of annotation (package-info.java)
@MyAnnotation
package com.myexample
The following does not seem to work (although it does compile) - my annotation processor does not detected any of the classes in the package com.myexample:
MyAnnotation.kt
package com.myexample.annotation
@Target(allowedTargets = [AnnotationTarget.CLASS, AnnotationTarget.FILE])
@Retention(AnnotationRetention.SOURCE)
annotation class MyAnnotation
package-info.kt
@file:MyAnnotation
package com.myexample
import com.myexample.annotation.MyAnnotation
Upvotes: 2
Views: 1001
Reputation: 97128
No, it's not currently possible. You can simply leave package-info.java as a Java file.
Upvotes: 2