tangens
tangens

Reputation: 39753

Can I configure a resource path that contains java source files in eclipse?

Motivation

In eclipse I'd like to configure a path as a resource path. This path contains some java files that I only want to handle as resources, i.e. I don't want eclipse to try to compile these files. I only want to read them as resources from within junit tests.

Question

Is there a way to configure eclipse so it won't try to compile the java files it found there?

Upvotes: 4

Views: 1905

Answers (3)

Eugene Kuleshov
Eugene Kuleshov

Reputation: 31795

You can specify excludes for *.java files in project properties / Build Path / Sources preferences. However in that case *.java won't be copied into the target folder, so those resources won't be available at runtime classpath. To get around that, after adding excludes you can add a custom builder (e.g. Ant script) that would copy *.java files over.

Alternatively, you can use m2eclipse with Maven-enabled project and place your java files into src/main/resources, so all files from that folder won't be compiled, but they will be copied into the result classpath.

Also, you can try to point target folder to the same dir as source folder.

Upvotes: 1

Timo Westkämper
Timo Westkämper

Reputation: 22200

Check Included=All and Excluded=**/*.java for the specific source folder in the Java Build Path through the Project properties.

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

Upvotes: 0

Fede
Fede

Reputation: 945

You can remove the folder from build-path:

  1. Right click on project -> Build Path -> Configure Build Path
  2. Select tab "Source"
  3. Remove the folder you want only to handle as resources

Eclipse won't compile Java files in that folder

Upvotes: 0

Related Questions