从 Perforce Eclipse Plugin 将项目导入为 Java 项目

发布于 2024-10-13 19:54:13 字数 134 浏览 6 评论 0原文

我正在尝试从 Eclipse 中的 Perforce 工作区导入一个项目。它正在导入它(将文件提取到 java 包层次结构中),但问题是它没有作为“Java 项目”导入。所以我无法编辑“构建路径”或者没有类路径之类的东西。

有什么想法吗?

I am trying import a project from Perforce workspace in Eclipse. It is importing it (fetching the files into java package hierarchy) but the problem is it is not importing as "Java project". so i can't edit the "Build path" or there is no classpath or something.

Any idea?

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

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

发布评论

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

评论(2

帅气称霸 2024-10-20 19:54:13

您需要确保将 Eclipse 元数据文件放入源代码控制系统中。所有以 .在项目根目录以及整个 .settings 目录中,需要与源一起签入。如果您不这样做,Eclipse 将丢失有关项目类型以及应如何配置的所有知识。

You need to make sure to put Eclipse metadata files into your source control system. All files starting with . in the project root along with entire .settings directory need to get checked in along with your source. If you don't do that, Eclipse will loose all knowledge of the type of projects that it is and how it supposed to be configured.

杀手六號 2024-10-20 19:54:13

如果 Perforce 中的项目不包含常规 Eclipse java 项目的文件,您可以使用 Java Nature 创建另一个项目。将项目保留为空。

File > New > Java Project

它将为您创建以下文件。

.classpath
.project
.settings/org.eclipse.jdt.core.prefs

默认情况下,此空项目的源文件夹设置为“src”。
现在您必须将上面提到的前两个文件复制到 Perforce 工作区目录中。关闭并重新打开项目。

如果仍有问题,请检查文件 .project。它应该包含自然部分。

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Dev-Project_03_04_2016</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

现在检查您的 .classpath 文件。由于您从空白项目复制它,因此它包含类似以下内容:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>             
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>     
    <classpathentry kind="output" path="bin"/>
</classpath>

您需要删除此默认的默认“src”文件夹并添加源文件夹,当然,如果您不会在 Eclipse 中进行开发,则不需要所有这些。如果你做的一切都正确,并且还添加了 JUnit Nature,你将得到如下内容:

 <?xml version="1.0" encoding="UTF-8"?>
<classpath> 
    <classpathentry kind="src" path="bb/apps/911access-zip/components/911emergencydriver-ejb/src/main/java"/>
    <classpathentry kind="src" path="bb/apps/911access-zip/components/911accessmodel-ejb/src/main/java"/>
    <classpathentry kind="src" path="bb/apps/911access-zip/components/911accessplugin-ejb/src/main/java"/>  
    <classpathentry kind="src" path="bb/apps/911access-zip/src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    <classpathentry kind="output" path="bin"/>
</classpath>

If your Project in Perforce do not contain files of regular Eclipse java projects you can create another project with Java Nature. Keep Project empty.

File > New > Java Project

It will create for you following files.

.classpath
.project
.settings/org.eclipse.jdt.core.prefs

With this empty project by default your source folder is set to "src".
Now you have to copy first two files mentioned above to your Perforce workspace directory. Close and reopen project.

If you still have issues please check file .project. It should contain Nature section.

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Dev-Project_03_04_2016</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
        <buildCommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildCommand>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

Now Check your .classpath File. Since you copied it from blank project it contains something like:

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>             
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>     
    <classpathentry kind="output" path="bin"/>
</classpath>

You need to remove this default default "src" folder and add your source folders, of course if you wont do development in eclipse you do not need all this. If you did everything correctly, andded also JUnit Nature you wil get something as follows:

 <?xml version="1.0" encoding="UTF-8"?>
<classpath> 
    <classpathentry kind="src" path="bb/apps/911access-zip/components/911emergencydriver-ejb/src/main/java"/>
    <classpathentry kind="src" path="bb/apps/911access-zip/components/911accessmodel-ejb/src/main/java"/>
    <classpathentry kind="src" path="bb/apps/911access-zip/components/911accessplugin-ejb/src/main/java"/>  
    <classpathentry kind="src" path="bb/apps/911access-zip/src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    <classpathentry kind="output" path="bin"/>
</classpath>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文