Removal Advice Tool
This is a simple javac
annotation processor, which produces compilation warnings for code elements annotated with @Remove
, @RemoveInVersion
and @RemoveAfterDate
annotations.
Essentially, these are TODOs, done the annotation processor way!
repositories {
jcenter()
}
dependencies {
compileOnly group: 'ru.jihor.rat', name: 'rat', version: '<version>'
// or
// compileOnly 'ru.jihor.rat:rat:<version>'
}
<dependency>
<groupId>ru.jihor.rat</groupId>
<artifactId>rat</artifactId>
<version>(version)</version>
<type>pom</type>
</dependency>
The following annotations are available:
@Remove
: denotes that the element should be removedreason
(optional) @RemoveInVersion
: denotes that the element should be removed in an upcoming version (e.g. 2.0
) version
(mandatory, in any sensible format)reason
(optional) @RemoveInVersion(version = "2.0")
will produce a warning in a 2.0-SNAPSHOT
build @RemoveAfterDate
: denotes that the element should be removed after a certain datedate
(mandatory, in yyyy-MM-dd
format)reason
(optional) See ru.jihor.rat.Demo
in test
scope for examples.
The processor will work out-of-the-box, the only thing that needs to be passed is the project version to compare the version
in @RemoveInVersion
against.
This variable is controlled by rat.project.version
annotation processor option:
tasks.withType(JavaCompile) {
options.compilerArgs += ["-Arat.project.version=$project.version"]
}
// or, if Groovy is used:
tasks.withType(GroovyCompile) {
options.compilerArgs += ["-Arat.project.version=$project.version"]
}
The Gradle settings mentioned before will sadly NOT set the version for the annotation processor when Build
→Build project
is executed in IntelliJ Idea, because of this bug: https://youtrack.jetbrains.com/issue/IDEA-154038 .
The workaround is to open the IDE settings and set up the version manually in Build, Execution, Environment
-> Compiler
-> Java Compiler
-> Additional command line parameters
: -Arat.project.version=<project version>