Eclipse 类路径条目仅用于测试 [英] Eclipse classpath entries only used for tests
问题描述
在 Maven 中,您可以拥有 compile-time 依赖项和 test 依赖项.这是我喜欢的一个特性,M2Eclipse 插件也使 Eclipse 可以使用它,这很棒.因此,如果我将 jmock.jar
作为测试依赖项添加到我的项目中,它将显示在 JUnit 测试的类路径中,但在我调试应用程序本身时不会出现.>
这正是我现在想要实现的,但没有 M2Eclipse 或 Maven.有没有办法在普通的 Eclipse 中做到这一点?(可能无需安装任何插件.)
恐怕答案是你不能.有 2 个未解决的问题从 3.5 推迟到与您的问题相关:
In Maven, you can have compile-time dependencies and test dependencies. This is a feature I love, and the M2Eclipse plugin makes this available in Eclipse, too, which is great. So if I add jmock.jar
to my project as a test dependency, it will show up on the classpath for JUnit tests, but won't be present when I'm debugging the application itself.
This is exactly what I'd like to achieve now, but without M2Eclipse or Maven. Is there a way to do this in plain Eclipse? (Possibly without installing any plugins.)
I'm afraid the answer is that you can't. There are 2 open issues which were postponed from 3.5 related to your problem:
- Ability to mark source folder as test sources
- [buildpath] Should be able to ignore warnings from certain source folders
这篇关于Eclipse 类路径条目仅用于测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!