eclipse项目和编译数据
在包含 JUnit 测试的 Java Eclipse 项目中,我还有一个包“资源”,其中包含用于测试的所有输入数据。但是在编译 JUnit 测试时,Java 还编译资源中可用的数据,因此我在“bin”文件夹中找到了相同的数据。有办法避免这种情况吗?
谢谢。
in my Java Eclipse project that contains JUnit tests, I also have a package "resource" that contains all input data used for the tests. But when compiling JUnit tests, the Java compile also data available in resources, so I find the same data in the "bin" folder. Is there a way to avoid this?
thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您想要排除源路径中的特定包(例如您的资源文件夹),您可以右键单击该包并选择:
Build Path >排除
。这将告诉 Eclipse 您不想将该包包含在构建中。
这做出了几个假设:您正在使用 Eclipse Helios(因为旧版本中的选项可能有所不同),并且资源存储在与常规 java 源文件相同的文件夹中(因为如果资源位于文件夹本身,您可以使用
构建路径>配置构建路径
更新:
从构建中 删除整个文件夹。关于为什么您愿意或不愿意将资源复制到 bin 目录中:
bin
应该是.cvsignore
文件中的条目)所以,实际上(除了一些未知的,比如文件有数百GB之类的。 ),我认为您不需要担心从构建中排除这些文件。
If you have a particular package within the source path you want to exclude (your resources folder for example), you can right click on the package and select:
Build Path > Exclude
.This will tell Eclipse that you don't want to include that package as part of the build.
This is making a couple of assumptions: that you're using Eclipse Helios (because the option might be different in older versions), and that the resources are stored in the same folder as your regular java source files (because if resources is in a folder by itself, you can remove that entire folder from the build by using
Build Path > Configure Build Path -> Source tab
.Update:
After the discussion in the comments regarding why you would or would not want to copy resources into the bin directory:
bin
should be an entry in the.cvsignore
file)Class.getResource
to access those resources, they need to be on the classpath somewhere. The bin directory is as good a place as anySo, realistically (barring some unknown, like the files are hundreds of gigabytes or something), I don't think you need to be concerned about excluding these files from the build.