Add Gradle test for additional kapt arguments

This commit is contained in:
Yan Zhulanow
2015-06-16 19:29:28 +03:00
parent 7f2bd5b9d4
commit 8a10de3a26
4 changed files with 71 additions and 1 deletions
@@ -11,6 +11,7 @@ public class ExampleAnnotationProcessor : AbstractProcessor() {
private companion object {
val ANNOTATION_FQ_NAME = javaClass<ExampleAnnotation>().getCanonicalName()
val SUFFIX_OPTION = "suffix"
}
override fun process(annotations: MutableSet<out TypeElement>?, roundEnv: RoundEnvironment): Boolean {
@@ -19,9 +20,11 @@ public class ExampleAnnotationProcessor : AbstractProcessor() {
val elementUtils = processingEnv.getElementUtils()
val filer = processingEnv.getFiler()
val generatedFileSuffix = processingEnv.getOptions().get(SUFFIX_OPTION) ?: "Generated"
for (element in elements) {
val packageName = elementUtils.getPackageOf(element).getQualifiedName().toString()
val className = element.getSimpleName().toString().capitalize() + "Generated"
val className = element.getSimpleName().toString().capitalize() + generatedFileSuffix
filer.createSourceFile(className).openWriter().use { with(it) {
appendln("package $packageName;")
@@ -36,4 +39,6 @@ public class ExampleAnnotationProcessor : AbstractProcessor() {
override fun getSupportedSourceVersion() = SourceVersion.RELEASE_6
override fun getSupportedAnnotationTypes() = setOf(ANNOTATION_FQ_NAME)
override fun getSupportedOptions() = setOf(SUFFIX_OPTION)
}