将 Subversion 代码签入 Eclipse 后,如何构建它?

发布于 2024-07-14 08:49:10 字数 701 浏览 10 评论 0原文

这个问题已经让我沮丧了一段时间了……

很多网站,比如 Sourceforge,都使用 SVN 或 Subversion 来管理他们的代码。 我在 C++ 中编译 SVN 代码没有什么问题,但是当涉及到 Java 时,我的 IDE 让我头疼。

我已经安装了 Subclipse 以支持 Eclipse 的 SVN,并且它可以工作。 我可以将任何代码签入我的工作区。 现在 Subclipse 会将整个内容放入某种无法编译的特殊项目中。 因此,我在 Google 上搜索了一些内容,然后修改了 eclipse XML 文件以将“性质”指定为 Java 项目。

好的,现在是一个 Java 项目了。 假设我的文件夹结构如下:

\src
\data
\graphics

我收到 800 个编译器错误,抱怨包名称是 org.company.SomePackage 而不是 src.org.company.SomePackage。

然后我要做的就是创建名为 src、数据、图形等的,而不仅仅是文件夹。 我将文件夹中的所有内容剪切并粘贴到包中,终于我可以编译它。

有什么更好的方法来做到这一点?

编辑:我只能将任何 SVN 作为 SVN 项目签出,并且在 Eclipse 中无法将其更改为 Java 项目。 我如何首先将 SVN 作为 java 项目进行检查?

This problem has been frustrating me for some time...

A lot of sites like Sourceforge use SVN or Subversion to manage their code. I have little problem compiling SVN code in C++, but when it comes to Java, my IDE gives me a headache.

I've installed Subclipse for SVN support for Eclipse, and it works. I can check out any code into my Workspace. Now Subclipse will put the whole thing into a special project of some sort that can't be compiled. So I search Google for something and I come up with modifying the eclipse XML file to specify the 'nature' to be a Java project.

Okay, now it's a Java project. Say I have a folder structure like:

\src
\data
\graphics

I get 800 compiler errors complaining the package name is org.company.SomePackage instead of src.org.company.SomePackage.

Then what I do is create packages called src, data, graphics, etc, instead of just folders. I cut and paste everything in the folders into the packages and finally I can compile it.

What is a better way to do this?

EDIT: I can only check out anything SVN as a SVN project, and there's no way within Eclipse to change that to a Java project. How can I check out the SVN as a java project in the first place?

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

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

发布评论

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

评论(4

世界和平 2024-07-21 08:49:10

我收到 800 编译器错误抱怨
包名称是
org.company.SomePackage 而不是
src.org.company.SomePackage。

右键单击项目-> 属性-> Java 构建路径 -> 来源选项卡 -> 添加“src”作为源文件夹并删除其他任何文件夹。

I get 800 compiler errors complaining
the package name is
org.company.SomePackage instead of
src.org.company.SomePackage.

Right click on Project -> Properties -> Java Build Path -> Source Tab -> Add "src" as a source folder and remove any others.

蓝颜夕 2024-07-21 08:49:10

它认为您的源存储在根文件夹中。 您需要向项目指定 /src 是源文件夹。

it thinks your source is stored in root folder. you need to specify to the project that /src is the source folder.

暗地喜欢 2024-07-21 08:49:10

一般来说,当我们有一个包含 Java 代码的 Eclipse 项目时,但我们在创建或签出该项目时并未将其设置为 Java 项目,我们会感到震惊。 并且 Eclipse 不允许更改 Gui 内的项目类型。 所以我们需要添加如下的java性质。
1. 关闭您的项目。
2. 使用默认编辑器打开名为 .project 的项目文件(位于相应项目的根目录中)。 搜索

< natures>
< /natures>

并更改为如下

< natures>
<nature>org.eclipse.jdt.core.javanature</nature>
< /natures>

保存更改的文件。
3. 再次打开项目 – 现在它应该成为一个 java 项目。

然后按照 Kevin 的解释执行以下操作
在 Project Explorer 窗口 -> 右键单击​​特定项目 -> 属性-> Java 构建路径 -> 来源选项卡 -> 添加“src”作为源文件夹并删除其他任何文件夹。
对我来说,当我进入“源选项卡”时,“src”文件夹已经添加,但它没有给我想要的结果(即我仍然没有在项目资源管理器窗口中看到 .java 文件)。 因此,我删除了“源”选项卡中已添加的“src”文件,然后再次添加它们。 然后一切正常。

In general when we have an Eclipse project, which contains Java code – but we didn’t set it up as a Java project when we created or checked out this project, we are struck. And Eclipse doesn’t allow to change the project type inside the Gui. So we need to add the java nature as below.
1. Close your project.
2. Open your project file (which is located in your root directory of the appropriate project) called .project with your default editor. Search for

< natures>
< /natures>

and change it to as below

< natures>
<nature>org.eclipse.jdt.core.javanature</nature>
< /natures>

Save the changed file.
3. Open the project again – now it should become a java project.

Then do the following as explained by Kevin
On the Project Explorer Window ->Right click on the specific Project -> Properties -> Java Build Path -> Source Tab -> Add "src" as a source folder and remove any others.
For me when I went into “Source Tab” – the “src” folder was already added, but it was not giving me the desired result (ie I was still not seeing the .java files in the project explorer window). So I removed the “src” filed that was already added in the Source Tab and then added them again. And then all worked fine.

揽月 2024-07-21 08:49:10

您必须配置正确的源路径。 一些开源项目通过将其 .project 和 .classpath 文件与其余文件一起检查来自动执行此操作。 对于其他人来说,您将遇到与您完全相同的问题。 您需要设置类路径,以便 Java 编译器知道在哪里找到源代码。 您右键单击该项目并选择属性并配置任意类路径,但 Kevin 给出的答案对于初学者来说更容易。

You have to configure proper source paths. Some open source projects make this automatic by checking their .project and .classpath files in with the rest of their files. For others, you'll have exactly the problem you are having. You need to set the classpath so the Java compiler knows where to find the source. You right click on the project and select properties and configure an arbitrary classpath, but the answer given by Kevin is easier for a beginner.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文