ArcBees / gwtquery

A jQuery clone for GWT, and much more.
MIT License
85 stars 38 forks source link

JsniBundle : Unable to read javascript file #271

Closed han39 closed 10 years ago

han39 commented 10 years ago

I use JsniBundle to load some javascript files in my EntryPoint :

interface JqueryBundle extends JsniBundle { JqueryBundle INSTANCE = GWT.create(JqueryBundle.class); @LibrarySource(value = "resources/js/jquery-2.0.3.min.js") public void initJQuery(); }

interface MobiscrollJsniResource extends JsniBundle { MobiscrollJsniResource INSTANCE = GWT.create(MobiscrollJsniResource.class); @LibrarySource(value = "resources/js/mobiscroll.custom-2.9.0.min.js") public void mobiscroll(); }

When I Compile my project, I have those errors :

Invoking generator com.google.gwt.query.rebind.JsniBundleGenerator [INFO] JsniBundleGenerator - importing external javascript: fr\agfahealthcare\gwtmobiscroll\client\resources/js/jquery-2.0.3.min.js [INFO] [ERROR] Unable to read javascript file: fr\agfahealthcare\gwtmobiscroll\client\resources/js/jquery-2.0.3.min.js ...

to succeed my compilation, I did some changes in a local 1.4.1-SNAPSHOT copy :

JsniBundleGenerator class : line 97 : String content = getContent(logger, packageName.replace(".", "/") , value); line 132 : String file = path + "/" + src;

I also modified the getContent method to manage relative and absolute path to source file :

String file = path + "/" + src; in = this.getClass().getClassLoader().getResourceAsStream(file); if (in == null) { // If we didn't find the resource relative to the package, assume it is absolute. file = src; in = this.getClass().getClassLoader().getResourceAsStream(file); } if (in == null) { logger.log(TreeLogger.ERROR, "Unable to read javascript file: " + file); } else { logger.log(TreeLogger.INFO, getClass().getSimpleName() + " - importing external javascript: " + file); }

han39 commented 10 years ago

Is it possible to add the absolute path to load the resource ? I have an error when I want to access a different package :

@LibrarySource(value = "../resources/js/jquery.highlight.js") void hightlight();

[INFO] Computing all possible rebind results for 'fr.agfahealthcare.cassis.tools.JqueryHighlight.HighlightJsniResource' [INFO] Rebinding fr.agfahealthcare.cassis.tools.JqueryHighlight.HighlightJsniResource [INFO] Invoking generator com.google.gwt.query.rebind.JsniBundleGenerator [INFO] JsniBundleGenerator - importing external javascript: fr/agfahealthcare/cassis/tools/../resources/js/jquery.highlight.js [INFO] [ERROR] Unable to read javascript file: fr/agfahealthcare/cassis/tools/../resources/js/jquery.highlight.js [INFO] [ERROR] Error parsing javascript source: ../resources/js/jquery.highlight.js null [INFO] [ERROR] Errors in 'fr/agfahealthcare/cassis/tools/JqueryHighlight.java'

Thanks