I'm trying to export a specific package and its sub-packages as a non-runnable jar in Eclipse. I right click the package I want to export and hit "Export". However, when I export the jar, it only exports the top level package I've selected and all of its classes.
What I want is to export all sub-packages with it automatically as well. The only way I've been able to do this so far is to actually select each sub-package (and their sub-packages, etc...) for exporting as well. Is there any way to select all sub-packages for exporting as well automatically?
An example (with image):
I want to export the "bar1" package as a jar. I right click the bar1 package, click "Export" and select JAR. However, bar1's sub-package, "util". Is not selected by default and will not be exported. If I wanted to export bar1's sub-packages, I would need to select them individually. This is a pain if there are a lot of packages. Is there any way to have Eclipse add the "util" sub-package for exporting when I try to export the "bar1" package?
I think what you have is correct and there is not a lot of automation or easier way beside clicking your way through it to select a specific package and sub-packages. However, I think you can use ant or maven to do this for you which is much automated and easier. Here is how you can select specific package in ant :
<dirset dir="aDirectory">
<include name="a/package/**"/>
<exclude name="**/package/to/exclude**"/>
</dirset>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With