Add Gradle test for additional kapt arguments
This commit is contained in:
+6
-1
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user