diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/GeneratedModelWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/GeneratedModelWriter.kt index fefc5d7383..15fd97a4c0 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/GeneratedModelWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/GeneratedModelWriter.kt @@ -58,7 +58,8 @@ class GeneratedModelWriter( asyncable: Asyncable ) { - val modelInterfaceWriter = ModelBuilderInterfaceWriter(filer, types, asyncable) + val modelInterfaceWriter = + ModelBuilderInterfaceWriter(filer, types, asyncable, configManager, elements) open class BuilderHooks { open fun beforeFinalBuild(builder: TypeSpec.Builder) {} diff --git a/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/ModelBuilderInterfaceWriter.kt b/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/ModelBuilderInterfaceWriter.kt index 1675d61f46..716202f9e4 100644 --- a/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/ModelBuilderInterfaceWriter.kt +++ b/epoxy-processor/src/main/java/com/airbnb/epoxy/processor/ModelBuilderInterfaceWriter.kt @@ -10,6 +10,7 @@ import java.util.concurrent.ConcurrentHashMap import javax.annotation.processing.Filer import javax.lang.model.element.Modifier import javax.lang.model.element.TypeElement +import javax.lang.model.util.Elements import javax.lang.model.util.Types const val MODEL_BUILDER_INTERFACE_SUFFIX = "Builder" @@ -24,7 +25,9 @@ const val MODEL_BUILDER_INTERFACE_SUFFIX = "Builder" class ModelBuilderInterfaceWriter( private val filer: Filer, val types: Types, - val asyncable: Asyncable + val asyncable: Asyncable, + val configManager: ConfigManager, + val elements: Elements ) : Asyncable by asyncable { private val viewInterfacesToGenerate = ConcurrentHashMap() @@ -156,7 +159,11 @@ class ModelBuilderInterfaceWriter( } } - JavaFile.builder(interfaceName.packageName(), interfaceSpec) + val implementingViewTypeElement = details.implementingViews.firstOrNull() + val packageName = implementingViewTypeElement?.let { + configManager.getModelViewConfig(it)?.rClass?.packageName() + } ?: interfaceName.packageName() + JavaFile.builder(packageName, interfaceSpec) .build() .writeSynchronized(filer) }