开发者

Separate class paths for test code and main code

I have two source trees in my Java application in Eclipse. One is "src", and one is "test". Each one contains a directory tree of .java files. So far, so good.

However, I would like the classes in "test" to be able to see the classes in "src", but for the classes in "src" to not be able to see the classes in "test". Similarly, I want to include some test libraries. I don't want any of those libraries to be available in the "main" tree, les开发者_运维技巧t I accidentally use one without thinking.

Is there an easy way to set this up in Eclipse?


There is no way to solve this in Eclipse without splitting the two source trees into separate projects (with one depending on the other). Maven could handle that at build time though.


You don't need separate projects if you use IntelliJ. You just specify application and test packages. It's possible to mark libraries as part of application and test as well.

Eclipse ought to have equivalent buried under all those plugins. If not, IntelliJ has a community edition now.

Or just use Ant. Personally, I prefer it to Maven. I find Maven to be too complex for such a simple job.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜