How to prevent Eclipse from cleaning the bin folder for each assembly?

Now I am doing a project using Eclipse, and I have some resource files (for example, image, text) stored in the bin folder, and these files are needed by the program.

However, with each build, Eclipse will try to empty the folder and then rebuild the project. When cleaning, it deletes the resource files in the folder. Anyway, to stop Eclipse from doing this?

I know that I can change the location of the files, but I'm also curious why Eclipse will do this, and whether it can be prevented.

Thanks!

+4
source share
4 answers

I can’t say exactly why he does this, but probably this is how Eclipse builds: an empty “output folder” and start compiling.

However, if you put your files in the source folder, Eclipse will simply copy the files to bin in each assembly and they will not disappear. He will do this with any file that he does not know how to compile, for example. .xml , .xsd , .png , etc.

+3
source

Go to Options Java Compiler Building and uncheck the Scrub output folders when cleaning projects box.

This is a trick for me. In my project, I have an Ant task that adds several configuration resources to the bin folder to include them in the classpath without having them in src

+7
source

You can use the maven style project and add resources to the resources folder.

Here is a link to the maven directory layout .

What project are you using in eclipse. You can disable the automatic creation feature in the Project menu. Which would stop the eclipse from cleaning projects automatically.

+3
source

Copy and paste your resources into the source folder. In eclipse, in the package explorer, find your project, then paste it into src. Then it makes it possible to copy the file or link to it. Click on the copy and it will be saved in / bin, but will not be deleted.

0
source

All Articles