Need Help Packaging a GWT Library Module into a JAR

雨燕双飞 提交于 2019-12-05 21:37:35

Either, I misunderstand your question, or you mis-correlated GWT compilation with Java byte-code compilation.

Traditional Java development

  1. Java source is compiled into Java byte-code .class files.
  2. Compiled .class files during development as well as during deployment.
  3. compiled .class files can be used in the classpath of both development and deployment
  4. It does not matter if the .class files are jars or in folder hierarchy as long as their location is compliant to their respective package namespace.
  5. Java source files cannot be deployed into the deployment class path, but you can deploy JSP source files into the war as JSPs.

Not so for GWT.

  1. GWT is client side development.
  2. GWT is compiled into Javascript.
  3. The resulting javascript are packaged into a war folder.
  4. i.e., GWT compiled into executable files are javascript files.
  5. GWT compilation requires all Java classes to be source files.
  6. Any Java library referenced by your Java classes must also be Java source files.

GWT war

  1. GWT also facilitates client side alignment and communication with server side.
  2. The server side is normally traditional Java deployed into JEE war structure.
  3. Therefore a deployment war has both GWT client compiled into javascript as well as JEE .class bytecode files.
  4. However, the GWT javascript files are placed in the URL-visible part of the war, together with HTML, CSS and other URL-addressable resources.
  5. Server side compiled java bytecode files or jars are placed into the class and lib directories which are not URL-addressable.

Therefore,

  1. GWT compiled deployment structures cannot be used for development.
  2. GWT is compiled into javascript deployment war structure.
  3. There is "no such thing" as packaging GWT compiled resources into a jar for deployment.
  4. Compiled GWT resources must be packaged into the URL-addressable side of the war.
  5. There is "no such thing" as classpath in the compiled javascript files. Any classpath concept within javascript is simulated for JSNI's convenience.

In Conclusion

Compiled GWT resources are unusable nor will they be visible for GWT development because ... GWT development requires java source, and GWT client deployment are javascript in war, and javascript is not like bytecode jars/files.

Therefore, in GWT, there is "no such thing" as packaging a jar that is usable for both development and for deployment. Some examples and tutorials do package development and deployment files into a single jar - but that jar is essentially a zip which you have to break up the deployment pieces from the development pieces first.

GWT Development jars = source jars,

GWT Deployment = war of javascript and resources.

Before you launch yourself into GWT development, you should have at least 3-6 months' experience writing traditional JEE apps with JSP, servlets, HTML and javascript. That would help you inculcate a strong sense of segregation of server-side vs client-side, war vs jar and hence understand why GWT was invented in the first place. You would understand the deployment process.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!