Hi team -- I have some questions about Anvil. I am...
# squarelibraries
d
Hi team -- I have some questions about Anvil. I am trying to autogenerate both a
MergeModules
and a
MergeComponent
that depends on that
MergeModules
. It looks something like this:
Copy code
@MergeModules(scope = MyScope::class)
public interface MyModule

@MergeComponent(
  scope = AnvilScope::class,
  dependencies = [],
  modules = [MyModule::class]
)
public interface MyComponent
However, Anvil complains that it can't resolve
MyModule
even though they are defined in the same generated file. Any thoughts?
r
Why do you need
@MergeModules
? Are you trying to merge multiple scopes?
d
yeah, I need two scopes in this case: all the modules that contribute to
MyScope
and `AnvilScope`(obviously these are fake scope names lol)
r
You can use
@MergeComponent
multiple times. With Anvil version 2.4.0 it’s a repeatable annotation:
Copy code
@MergeComponent(Scope1::class)
@MergeComponent(Scope2::class)
interface YourComponent
This should work.
d
Ooh intriguing! Thank you!
Is there a reason why the
MergeModules
approach doesnt work?
r
It should work. I need a full stacktrace + a sample project, because when custom code generators are involved there could be multiple reasons why it fails.