Eclipse是否可以像多个源文件夹一样具有多个输出文件夹 [英] Can Eclipse have multiple output folders just like multiple source folders

查看:101
本文介绍了Eclipse是否可以像多个源文件夹一样具有多个输出文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Eclipse项目,其中有两个源文件夹- src和 test。我希望将这两个文件夹中的内容放入单独的输出文件夹中。

I have an Eclipse project, which has two source folders - 'src', and 'test'. I would like the build from both these folders to go into separate output folders.

原因是,这两个文件夹都有一个名为ServiceProviders.properties的属性文件,该文件具有不同的值用于代码的生产和测试运行。

The reason being, both these folders have a property file called ServiceProviders.properties which has different values for production and test runs of the code.

问题是,由于只有一个输出文件夹可以复制所有编译的类,因此不会复制'test'中的属性文件,因此我测试代码获取属性文件的生产版本。我想我正在尝试模拟在Maven中具有不同类路径的方式(及其查找顺序)。

The problem is, since there is only one output folder where all compiled classes are copied, the properties file in 'test' does not get copied, and as a result my test code gets the production version of the properties file. I guess I am trying to simulate the way we can have different classpaths in Maven (and their lookup order).

如果这不起作用,我将使用JVM属性指定可以在测试用例中使用的某些值。但是,这似乎不是一个很好的解决方案。

If this does not work, I will use a JVM property to specify certain values which I can use in the test case. However, it does not seem like an elegant solution.

使用Maven可以使它工作,但是我不能在该项目中使用Maven。

Using Maven will get this to work, but I cannot use Maven in this project.

更新1:

感谢您的回答。由于它们是相同的,因此我接受了之前发布的内容。

Thanks for both the answers. Since they were identical, I have accepted the one which was posted earlier.

Upadte 2:

即使我可以为对应的源文件夹获得多个输出文件夹,它也不能解决我原来的问题,即在运行测试用例时从测试加载ServiceProviders.properties,而在运行测试用例时从src加载Eclispe服务器上的应用程序。我使用它的方法是通过从测试文件夹中使用ServiceProviders.properties文件创建一个单独的jar文件。在测试用例的运行配置中,我添加了这个jar文件并更改了顺序,因此它似乎是查找的第一个依赖项。

Even though I could get multiple output folders for corresponding source folders, it did not solve my original problem which was to load a ServiceProviders.properties from test when I run test cases, and the one from src when I run the app on a server from Eclispe. The way I got it to work is by creating a separate jar file with ServiceProviders.properties file from the test folder. In the run configuration of my test cases, I add this jar file and change the order, so it appears as the first dependency for lookup.

推荐答案

是的,我刚刚检查了一下。
如果进入项目的属性,然后进入Java Build Path,从中选择不同的Source-Folders,则还有一个名为允许源文件夹的输出文件夹的选项,如果选中该选项,则会添加一个每个源文件夹的可编辑输出文件夹。
只需选择它,然后单击编辑按钮,就可以了

Yes it can, i just have checked that. If you go into Properties of your Project, and there to Java Build Path, where you choose your different Source-Folders, there also is an option called "Allow output folders for source folders", which, if checked adds an editable output-folder for each of your source-folders. just select it and click the edit-button and you're fine

这篇关于Eclipse是否可以像多个源文件夹一样具有多个输出文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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