views:

145

answers:

1

How to make eclipse treat a directory containing class files as a resource directory and make it copied to the output folder (bin) ?

My project Structure is like this

src
  com
    package1
       all source files (.java)
       image files
    package2
       some dependent class files (.class)
bin
  com
    package1
       generated .class files for source files
       image files
    package2
       (empty)

In eclipse I have specified exculsion filter to exclude the src\com\package2 from source folder list. And I have added the absolute path to src folder in buildpath, so the classes in src\com\package2 are available to build the source files.

Now I want to export the whole set of classes (generated and referenced) into JAR file. For that I need to have the src\com\package2 classes in bin\com\package2 folder which is now empty. Is there any way I can make eclipse treat the class files in src\com\package2 as resource files (like images in src\com\package1) and get them copied to bin\com\package2?

PS: Runnable JAR is not an option as I have so many libraries referenced.

+1  A: 

Create a new folder in root of project. Move your class files to that folder and add it as a 'class folder' in Java Build path. Now while exporting the jar you can select the class folder and you will get what you want in the jar.

Adi
You just need a separate folder that can be referenced in the Java build path. It does not have to be in the root of the project. For example, '/src/classes/com/package2' would work just as well as '/classes/com/package2'. Just make sure that you add '/src/classes' to the build path and not '/src/classes/com/package2' so that the folders get added to the JAR.
Faron
Faron, you are right. I gave answer which solves his problem without mixing source and class files. Ideally the class files should have gone to jar file with version info.
Adi