将源文件夹包含到 Eclipse 中的类路径中

发布于 2024-12-28 17:05:49 字数 226 浏览 1 评论 0原文

如果我将源文件夹添加为 Java 构建路径/库中的类文件夹,Eclipse 会抱怨。

我需要这个用于要求源位于类路径中的 GWT。一种解决方案是手动将所有项目的源文件夹添加到启动配置的类路径中,但由于特定原因,这不适合我。

另一个解决方案是告诉 Eclipse 将所有 *.java 文件复制到 bin 文件夹(就像其他资源一样),但我也无法实现这一点。

Eclipse complains if I add source folder as a class folder in Java Build Path / Library.

I need this for GWT that requires sources to be in the classpath. One solution is to manually add source folders of all projects to classpath of the launch configuration, but this is not suitable for me because of specific reasons.

Another solution would be to tell Eclipse to copy all *.java files to bin folder (as it does for other resources), but I can't achieve this too.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

星星的軌跡 2025-01-04 17:05:49

您是否使用 Google 的 GWT 插件 (http://code.google.com/eclipse/docs/getting_started.html)。虽然我没有使用过它,但我的一个同事用过它,并且我有理由确信它可以处理类路径问题中的此类 java 代码。

Are you using the GWT plug-in by Google (http://code.google.com/eclipse/docs/getting_started.html). Although I have not used it, a collegue of mine did, and I am reasonably sure it handles this kind of java code in the classpath issue.

看轻我的陪伴 2025-01-04 17:05:49

我找到了解决方案 - 将 Ant 构建器添加到指向以下 ant 文件的所有项目:

<project name="Copy Sources" basedir="." default="copy-src">
    <target name="copy-src">
        <copy todir="bin">
            <fileset dir="src" includes="**/*.java"/>
        </copy>
    </target>
</project>

我的 .project 文件如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>my-project1</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
            <triggers>auto,full,incremental,</triggers>
            <arguments>
                <dictionary>
                    <key>LaunchConfigHandle</key>
                    <value><?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration local="false" path="/gwt-dev-support/Copy Sources.launch"/></value>
                </dictionary>
                <dictionary>
                    <key>incclean</key>
                    <value>true</value>
                </dictionary>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

I've found the solution - to add Ant builder to all projects pointing to the following ant file:

<project name="Copy Sources" basedir="." default="copy-src">
    <target name="copy-src">
        <copy todir="bin">
            <fileset dir="src" includes="**/*.java"/>
        </copy>
    </target>
</project>

My .project files look like this:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>my-project1</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
        <buildCommand>
            <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
            <triggers>auto,full,incremental,</triggers>
            <arguments>
                <dictionary>
                    <key>LaunchConfigHandle</key>
                    <value><?xml version="1.0" encoding="UTF-8"?>
<launchConfiguration local="false" path="/gwt-dev-support/Copy Sources.launch"/></value>
                </dictionary>
                <dictionary>
                    <key>incclean</key>
                    <value>true</value>
                </dictionary>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文