I've tried to modularise my app into a 3 jars, two of which have modules, the dependency is linear (1 <- 2 <- 3): 1 does not have a Dagger module, 2 does (and compiles fine), 3 includes 2's module and fails to compile citing that it can't find a class that 2's module provides:
(in /home/adam/repos/mapdone, development)
Compiling mapdone:desktop into /home/adam/repos/mapdone/desktop/target/classes
error: cannot access Stage
class file for com.badlogic.gdx.scenes.scene2d.Stage not found
Consult the following stack trace for details.
com.sun.tools.javac.code.Symbol$CompletionFailure: class file for com.badlogic.gdx.scenes.scene2d.Stage not found
/home/adam/repos/mapdone/desktop/src/main/java/com/kaizen/mapdone/Desktop.java:31: error: cannot access ApplicationListener
new LwjglApplication(ui, appName, appSizeX, appSizeY, useGl2);
^
class file for com.badlogic.gdx.ApplicationListener not found
1 error
Buildr aborted!
RuntimeError : Failed to compile, see errors above
To put it another way; I'm extending a Dagger module from another module in my own jar, and when it's resolving something from the "base" module it's failing (it can't find the class in the jar, I think) -- am I mis-using Dagger?
The modules in question;
@Module(injects = Ui.class)
public class UiModule {
@Provides @Singleton Stage provideStage() {
return new Stage();
}
@Provides @Named("InitialParent") Node provideInitialParentNode() {
return new Node("initial parent node");
}
@Provides @Singleton ShapeRenderer provideShapeRenderer() {
return new ShapeRenderer();
}
@Provides @Singleton BitmapFont provideBitmapFont() {
return new BitmapFont();
}
}
@Module(
injects = Desktop.LwjglApplicationWrapper.class,
includes = UiModule.class
)
public class DesktopModule {
@Provides @Named("AppName")
String provideAppName() {
return "AppName";
}
@Provides @Named("AppSizeX")
int provideAppSizeX() {
return 800;
}
@Provides @Named("AppSizeY")
int provideAppSizeY() {
return 480;
}
@Provides @Named("UseGl2")
boolean provideUseGl2() {
return false;
}
}
And the relevant signatures;
public static class LwjglApplicationWrapper {
@Inject
public LwjglApplicationWrapper(final Ui ui, @Named("AppName") final String appName, final @Named("AppSizeX") int appSizeX, final @Named("AppSizeY") int appSizeY, final @Named("UseGl2") boolean useGl2) {
new LwjglApplication(ui, appName, appSizeX, appSizeY, useGl2);
}
}
@Inject
public Ui(final Lazy<Stage> lazyStage, final Lazy<Map> lazyMap, final GdxInput gdxInput, final GdxGraphics gdxGraphics, final GdxGl gdxGl)
I've tried to modularise my app into a 3 jars, two of which have modules, the dependency is linear (1 <- 2 <- 3): 1 does not have a Dagger module, 2 does (and compiles fine), 3 includes 2's module and fails to compile citing that it can't find a class that 2's module provides:
To put it another way; I'm extending a Dagger module from another module in my own jar, and when it's resolving something from the "base" module it's failing (it can't find the class in the jar, I think) -- am I mis-using Dagger?
The modules in question;
And the relevant signatures;