Eclipse 3.4 GWT 1.6 项目 - 如何从其他项目引用源代码? [英] Eclipse 3.4 GWT 1.6 project - how to reference source from other projects?
问题描述
我在 Eclipse 3.4 中有一个 GWT 1.6 项目,我正在尝试从我的工作区中的另一个(非 GWT)项目引用源代码.我已将该项目添加到我的构建路径,但我无法在托管模式下运行该应用程序.当我这样做时,我收到没有可用的源代码"错误.
I've got a GWT 1.6 project in Eclipse 3.4 and am trying to reference source from another (non-GWT) project in my workspace. I've added the project to my build path, but I can't run the application in hosted mode. When I do, I get a "no source code is available" error.
我进行了一些搜索和阅读,并尝试了其他人建议的一些方法(包括从依赖项目创建一个 jar 并链接到它),但坦率地说,没有任何效果.
I've done some searching and reading and have tried a few things that others have suggested (including creating a jar from the dependent project and linking to it), but frankly nothing has worked.
如果你真的这样做了,你能帮我做一个简单的分步设置吗?我真的很感激,谢谢!
If you're actually doing this, could you please help me out with a simple step-by-step setup? I'd really appreciate it, thanks!
推荐答案
我有 2 个 Eclipse 项目.一个是gwt项目,一个不是.这是对我有用的目录结构:
I have 2 Eclipse Projects. One is gwt project and one is not. Here's the directory structure that works for me:
workspace
-- gwt-project
-- src/main/java
-- com.gwt.GwtProjectModule
-- GwtProjectModule.gwt.xml
-- non-gwt-project
-- src/main/java
-- com.nongwt.package.that.contains.source.you.need
-- nongwt.gwt.xml
-- com.nongwt.package.that.contains.source.you.need.client
nongwt.gwt.xml 告诉 gwt 查看client"包的内部,如下所示:
nongwt.gwt.xml tells gwt to look inside "client" package, here's what it looks like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.0/distro-source/core/src/gwt-module.dtd">
<module rename-to='nongwt'>
<inherits name='com.google.gwt.user.User' />
<source path="client" />
</module>
GwtProjectModule.gwt.xml 然后可以从 nongwt 继承源代码.这是 GwtProjectModule.gwt.xml 中的相关行:
GwtProjectModule.gwt.xml can then inherit source code from nongwt. Here's the relevant line from inside GwtProjectModule.gwt.xml:
<inherits name="com.nongwt.package.that.contains.source.you.need.nongwt" />
确保在 Eclipse 中将非 gwt-project 包含在 gwt-project 的类路径中.这是正常的练习;右键单击gwt-project,选择属性,选择Java Build Path",单击Projects"选项卡,然后选择non-gwt-project"
Make sure you include non-gwt-project inside gwt-project's classpath in eclipse. It's the normal drill; right click on gwt-project, choose properties, choose "Java Build Path", click "Projects" tab, and "non-gwt-project"
或者,除了在gwt-project的classpath中包含non-gwt-project作为项目引用之外,还可以将non-gwt--project的内容进行jar包,确保jar中包含源码,然后包含gwt-project 类路径中的 jar.
Or, instead of including non-gwt-project in gwt-project's classpath as a project reference, you can also jar the contents of non-gwt--project, ensure that you include the source in the jar, and then include the jar in gwt-project's classpath.
祝你好运!
这篇关于Eclipse 3.4 GWT 1.6 项目 - 如何从其他项目引用源代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!