如何在单个Eclipse项目中设置多个源文件夹? [英] How to set up multiple source folders within a single Eclipse project?

查看:253
本文介绍了如何在单个Eclipse项目中设置多个源文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个单独的程序,在概念上可以适应一个单一的项目。但是,我无法告诉Eclipse在项目文件夹中创建多个文件夹。



结构的一个简单形式是:

  / UberProject 
/ UberProject / ProgramA /
/UberProject/ProgramA/com/pkg/NiftyReader.java
/ UberProject / ProgramB /
/UberProject/ProgramB/com/pkg/NiftyWriter.java

ProgramA ProgramB 都是项目(实际上它们是现有的Java项目),从概念上讲, code> UberProject 。



我不认为我应该使 UberProject 成为一个Java项目;它不是一个类路径,例如。 ProgramA ProgramB do 似乎应该是Java项目(他们可能会使用不同的构建依赖关系),但是我在Eclipse 3.3中看不到在 UberProject 下创建两个旨在包含Java代码的文件夹。我想到在两个子项目中添加一个.project文件,但是我也不确定这个是合适的。 Eclipse帮助没有帮助,我没有看到关于这个具体问题的任何事情。



只是为了明确:假设有必要存在的 UberProject UberProject 可以是Java项目,也可以不是;没关系。 (顺便说一下,它包含不包含Java代码的其他文件夹。)

解决方案

可能有以下几种方法:



1)UberProject是您的JavaProject。右键单击ProgramA - > Build Path - >用作源文件夹。右键单击ProgramB - > Build Path - >用作源文件夹。 ProgramA和ProgramB都将对同一个目录进行增量版本创建。



2)两个java项目(ProgramA和ProgramB)。您可以使用UberProject作为您的eclipse工作空间,这将是最简单的,也可以使用外部工作区,并将ProgramA和ProgramB作为外部项目导入。



可能还有其他方法(maven多模块项目)。您的选择可能取决于项目之间是否具有循环依赖关系。尝试1和2应该比较容易,看看最适合你的。


I have several somewhat separate programs, that conceptually can fit into a single project. However, I'm having trouble telling Eclipse to make several folders inside a project folder.

A simple form of the structure would be:

/UberProject
/UberProject/ProgramA/
/UberProject/ProgramA/com/pkg/NiftyReader.java
/UberProject/ProgramB/
/UberProject/ProgramB/com/pkg/NiftyWriter.java

That is, ProgramA and ProgramB are both projects (in fact, they're currently existing Java projects), which conceptually fit into UberProject.

I don't think I'm supposed to make UberProject be a Java project; it's not a classpath, for instance. ProgramA and ProgramB do seem like they should be Java projects (they might use different build dependencies as well), but I see no way in Eclipse 3.3 to create two folders under UberProject that are intended to contain Java code. I thought about adding a .project file to each of the two sub-projects, but I'm not sure that's appropriate, either. Eclipse help isn't being helpful, and I didn't see anything on SO about this specific problem.

Just to be clear: assume as given the necessity of the existence of UberProject. UberProject can be a Java project, or not; it doesn't matter. (Incidentally, it does contain other folders that do not contain Java code.)

解决方案

There are probably several ways to do this:

1) UberProject is your JavaProject. Right click ProgramA -> Build Path -> Use as source folder. Right click ProgramB -> Build Path -> Use as source folder. Both ProgramA and ProgramB will do incremental builds to the same directory.

2) Two java projects (ProgramA and ProgramB). You can use UberProject as your eclipse workspace which would be easiest or you can use an outside workspace and import ProgramA and ProgramB as external projects.

There are probably other ways as well (maven multi-module project). Your choice probably depends on whether you have cyclic dependencies between projects. It should be relatively easy to try both 1 and 2 and see what works best for you.

这篇关于如何在单个Eclipse项目中设置多个源文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆