How to exclude code from the final JAR file, but not the compilation process?
I have some test code that I would开发者_JAVA技巧 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!
Ideal way of doing it is to keep source and test in different source-folders as below:
Then export the src folder and test folder in to separate jars.
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.
精彩评论