Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7735636 authored by Jacky Wang's avatar Jacky Wang
Browse files

[Catalyst] try-catch for Filer.createSourceFile

A quick fix to avoid gradle build failure.

Bug: 385793553
Flag: EXEMPT library
Test: manual
Change-Id: I644e6701b9b0ca7cf81a676de7faf151a548cd71
parent ccd9843c
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -129,7 +129,15 @@ class PreferenceScreenAnnotationProcessor : AbstractProcessor() {
                )
            }
        }
        processingEnv.filer.createSourceFile("$outputPkg.$outputClass").openWriter().use {
        val javaFileObject =
            try {
                processingEnv.filer.createSourceFile("$outputPkg.$outputClass")
            } catch (e: Exception) {
                // quick fix: gradle runs this processor twice unexpectedly
                warn("cannot createSourceFile: $e")
                return
            }
        javaFileObject.openWriter().use {
            it.write("package $outputPkg;\n\n")
            it.write("import $PACKAGE.$PREFERENCE_SCREEN_METADATA;\n\n")
            it.write("// Generated by annotation processor for @$ANNOTATION_NAME\n")