Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Eclipse have multiple output folders just like multiple source folders

Tags:

java

eclipse

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.

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.

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).

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.

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

Update 1:

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

Upadte 2:

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.

like image 514
Parag Avatar asked Apr 16 '12 12:04

Parag


People also ask

What is the difference between source folder and folder in eclipse?

A source folder is marked by Eclipse as containing java sources. Then, when you compile your project Eclipse will look for your source code into all your source folders. You can make any folder become a source folder adding it to the java build path.

What is default output folder in eclipse?

Eclipse puts binaries in "project folder/bin/" by default.

What is source folder name in Eclipse?

The source folder is the one that holds your sources, usuglaly in the form: project/src/com/yourpackage/...


1 Answers

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

like image 76
reggaemuffin Avatar answered Oct 15 '22 07:10

reggaemuffin