use of com.google.gwt.dev.cfg.ModuleDef in project gwt-cs by iSergio.
the class CesiumScriptInjector method forceScriptLoad.
private boolean forceScriptLoad(TreeLogger logger, String moduleName, Float gwtVersion) {
try {
ModuleDef module;
Method getModuleDef;
if (gwtVersion < 2.6f) {
getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, String.class });
module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName);
} else if (gwtVersion < 2.8f) {
Class compilerContextClass = Class.forName("com.google.gwt.dev.CompilerContext");
Object context = compilerContextClass.getDeclaredConstructor().newInstance();
getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, compilerContextClass, String.class });
module = (ModuleDef) getModuleDef.invoke(null, logger, compilerContextClass.cast(context), moduleName);
} else {
getModuleDef = ModuleDefLoader.class.getDeclaredMethod("loadFromClassPath", new Class[] { TreeLogger.class, String.class, boolean.class });
module = (ModuleDef) getModuleDef.invoke(null, logger, moduleName, false);
}
if (module != null)
return CrossSiteIframeLinker.class.equals(module.getActivePrimaryLinker());
logger.log(TreeLogger.WARN, "Can't find module reference - not injecting scripts.");
} catch (Throwable t) {
logger.log(TreeLogger.ERROR, "Encountered an exception while trying to resolve the ModuleDef for " + moduleName, t);
}
return false;
}
Aggregations