user597474
user597474

Reputation:

How to exclude code from the final JAR file, but not the compilation process?

I have some test code that I would like to keep close to the code it's supposed to test. It's only used for debugging, and I don't want it in the final release jar, but I do want Eclipse to compile it. I know I could just put it in a separate project, but I'd prefer keeping it in the same one for organizational purposes, as it has no other use within the code base.

So, is it possible to tell Eclipse to exclude a particular package/file from the final JAR, but not the compilation process?

Thanks!

Upvotes: 1

Views: 271

Answers (2)

Suraj Chandran
Suraj Chandran

Reputation: 24791

Ideal way of doing it is to keep source and test in different source-folders as below:enter image description here

Then export the src folder and test folder in to separate jars.

Upvotes: 2

Amol Katdare
Amol Katdare

Reputation: 6760

Yes.

Once you invoke the "export as jar" wizard, it allows you to select packages that you would like included in the jar. customize to your requirements and dont forget to save your customization in the last step ("save this jar description" field) so that you dont have to go through the customization every time you want to build this jar.

Upvotes: 1

Related Questions