With GWTP/Gin, is it possible to optionally install a module during compile? We have a case where we would like to have a presenter and view only available in the application when running in "development" mode, where that mode is determined by a flag in the .gwt.xml file (set by the build).
Previously, we were running GXT with an MVC architecture and would do the following in our module:
<replace-with class="com.mypackage.DevEditController" >
<all>
<when-property-is name="isDevelopment" value="true" />
<when-type-is class="com.mypackage.EditController" />
</all>
</replace-with>
<replace-with class="com.mypackage.StubEditController" >
<all>
<when-property-is name="isDevelopment" value="false" />
<when-type-is class="com.mypackage.EditController" />
</all>
</replace-with>
And would create the controller with the following:
(EditController)GWT.create(EditController.class);
I would like to do something similar with GWTP, where the non-development compile of the application wouldn't know anything about this presenter. Essentially, doing something along the lines of this in our module file:
<set-configuration-property name="gin.ginjector.modules"
value="com.mypackage.gin.SharedModule"/>
if this is development mode:
<set-configuration-property name="gin.ginjector.module.desktop"
value="com.mypackage.gin.DevDesktopModule"/>
else:
<set-configuration-property name="gin.ginjector.module.desktop"
value="com.mypackage.gin.DesktopModule"/>
Where DesktopModule and DevModule would do the same things, but DevDesktopModule would load an additional module (TestModule) containing the presenter/view binding.
Is this doable from a configuration perspective? I thought I could do this with two .gwt.xml files switched out by the build process, but the build process always sees the TestModule file, regardless of whether or not it's being installed (apparently because of the Inject). This is the error message we get when the module is present in the source tree but never installed (this is from a build where we don't want it installed)
[ERROR] Error injecting com.blah.test.TestPresenter$MyView: Unable to create or inherit binding: No @Inject or default constructor found for com.blah.test.TestPresenter$MyView
Path to required node:
com.google.gwt.inject.client.AsyncProvider<com.blah.test.TestPresenter> [com.gwtplatform.mvp.client.ClientGinjector#getcomblahtestTestPresenter()]
-> com.blah.test.TestPresenter [Implicit injection of com.google.gwt.inject.client.AsyncProvider<com.blah.test.TestPresenter>]
-> com.blah.test.TestPresenter$MyView [@Inject constructor of com.blah.test.TestPresenter]
[ERROR] Errors in 'gen/com/gwtplatform/mvp/client/DesktopGinjectorProvider.java'
[ERROR] Line 8: Failed to resolve 'com.gwtplatform.mvp.client.DesktopGinjector' via deferred binding
[WARN] For the following type(s), generated source was never committed (did you forget to call commit()?)
[WARN] com.gwtplatform.mvp.client.com_gwtplatform_mvp_client_DesktopGinjectorImpl
I appreciate any insight into the issue, or alternative solutions for having a "conditionally included" module in our application.