简体   繁体   English

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

[英]Include source folder to classpath in Eclipse

Eclipse complains if I add source folder as a class folder in Java Build Path / Library. 如果我将源文件夹添加为Java Build Path / Library中的类文件夹,Eclipse会抱怨。

I need this for GWT that requires sources to be in the classpath. 对于需要源位于类路径中的GWT,我需要这样做。 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. 另一个解决方案是告诉Eclipse将所有*.java文件复制到bin文件夹(对其他资源也是如此),但是我也无法实现这一点。

Are you using the GWT plug-in by Google (http://code.google.com/eclipse/docs/getting_started.html). 您是否正在使用Google的GWT插件(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. 尽管我没有使用过它,但是我的一个同事使用了它,并且我有把握地确定它可以处理classpath问题中的这种Java代码。

I've found the solution - to add Ant builder to all projects pointing to the following ant file: 我找到了解决方案-将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>

My .project files look like this: 我的.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>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;launchConfiguration local=&quot;false&quot; path=&quot;/gwt-dev-support/Copy Sources.launch&quot;/&gt;</value>
                </dictionary>
                <dictionary>
                    <key>incclean</key>
                    <value>true</value>
                </dictionary>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM