Skip to content

Annotation processor raising errors for Deprecated annotations

License

Notifications You must be signed in to change notification settings

gotson/best-before

Repository files navigation

GitHub Workflow Status Maven Central Sonatype Nexus (Snapshots)

Best Before

An annotation processor for Java and Kotlin that will throw an error if @Deprecated code is found.

But why?

Deprecated code is usually removed on major releases. It can happen that we forget to remove deprecated code before shipping a new major version.

Best Before is here to handle those cases. By enabling the annotation processor during major versions, and failing the build if some deprecated code is found, one can ensure major versions are free of deprecated code.

How to use?

Best Before is composed of two annotation processors:

  • bestbefore-processor-java which handles java.lang.Deprecated
  • bestbefore-processor-kotlin which handles kotlin.Deprecated, and needs to be used with KSP

Apply the dependency only if the version is a major version:

Gradle (Groovy)

if (version.toString().contains(".0.0")) {
    annotationProcessor 'com.github.gotson.bestbefore:bestbefore-processor-java:0.1.0'
    ksp 'com.github.gotson.bestbefore:bestbefore-processor-kotlin:0.1.0'
}

Gradle (Kotlin DSL)

if (version.toString().contains(".0.0")) { 
  annotationProcessor("com.github.gotson.bestbefore:bestbefore-processor-java:0.1.0")
  ksp("com.github.gotson.bestbefore:bestbefore-processor-kotlin:0.1.0")
}