更新时间:2023-12-03 23:01:04
你宁愿在你想要的模块中创建一个子文件夹(也就是'超级')(可能是你想做的代码的模块可翻译的),并将它声明为 super-source
在你的模块的gwt.xml中:
< super-source path =super/>
然后你将 java / awt / Color.java code>在那里。
Eclipse错误是正常的,它不是应该编译的源代码(由javac编译为* .class文件)用于GWT编译的代码,它来自* .java文件。所以你想从构建路径中排除 super
子文件夹。
就是这样!
另请参阅 使用另一个子部分覆盖一个包实现 http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml
I have some code which uses java.awt.Color. I want to translate my Java Code to GWT. So I will emulate java.awt.Color in my GWT Project.
One approach is to write a module called java.AWT.gwt.xml whose source path is awt and a class called java.awt.Color.
The other approach is to create a folder com.google.gwt.emul.java.awt and create java.awt.Color class inside that path. Eclipse will show errors. But compiler will work.
Which one is appropriate way to add java.awt.Color for GWT?
You'd rather create a subfolder (say 'super') in whichever module you want (probably the module for the code you want to make "translatable") and declare it as a super-source
in your module's gwt.xml:
<super-source path="super" />
And you'd put your java/awt/Color.java
in there.
The Eclipse errors are normal, it's not source code that should be compiled (by javac, to a *.class file), only code for the GWT compile, which works from the *.java file. So you'd want to exclude the super
subfolder from your build path.
That's it!
See also the Overriding one package implementation with another subsection at http://code.google.com/webtoolkit/doc/latest/DevGuideOrganizingProjects.html#DevGuideModuleXml