2

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

1 Answer 1

2

No, it's not currently possible. You can simply leave package-info.java as a Java file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.