Can I customize a resource path containing java source files in eclipse?

Motivation

In eclipse, I would like to configure the path as the path to the resource. This path contains some java files that I want to process only as resources, i.e. I do not want eclipse trying to compile these files. I just want to read them as resources from junit tests.

Question

Is there a way to configure eclipse so that it does not try to compile java files found there?

+4
source share
3 answers

You can specify an exception for * .java files in the project properties / Build path / sources. However, in this case * .java will not be copied to the target folder, so these resources will not be available during the implementation path. To get around this, after adding exceptions, you can add a custom builder (for example, Ant script) that will copy * .java files.

Alternatively, you can use m2eclipse with a project with Maven support and put your java files in src / main / resources, so all the files from this folder will not be compiled, but they will be copied to the path to the result classes.

In addition, you can try to specify the target folder in the same directory as the source folder.

+1
source

Check Enabled = All and Excluded = ** / *. java for a specific source folder in the Java build path through project properties.

alt text http://img708.imageshack.us/img708/3509/eclipseexclusion.png

0
source

You can remove the folder from the build path:

  • Right-click on the project → Build Path → Configure Build Path
  • Select the Source tab
  • Delete the folder that you want to process only as resources.

Eclipse will not compile Java files in this folder

0
source

Source: https://habr.com/ru/post/1310362/


All Articles