1

I am embedding 3rd party JARs in pom.xml. The JARs have few classes which are not part of any package but I want to export these classes using the tag. Please help me how to do the same.

Johna
  • 85
  • 1
  • 8
  • you can [shade](https://maven.apache.org/plugins/maven-shade-plugin/) them. but remember that their dependencies will need to be carried also.. alternatively, i think you can embed that jar as your dependency and put it into the export tag in the `pom`. – Bagus Tesa May 30 '18 at 11:19
  • I am embedding that JAR but not sure how to add the class to the export tag and also will I need to add it to the export-package tag. – Johna May 30 '18 at 11:25
  • There is no such thing in Java as classes that are not part of any package. These classes belong to the default package, which has the name "", i.e. empty-string. – Neil Bartlett May 31 '18 at 07:28

1 Answers1

2

An OSGi bundle cannot import the default package, so there's no use in exporting it from your bundle.

Since you want to export the API, I assume you have one or more other bundles that need to use it. If you are in control of those bundles, I recommend that you try to wrap your own API around the classes that you need to make available. Create this API in a package of your own liking and export that package with the Export-Package header in your jar. See also this SO post: wrap-third-party-jar-that-imports-from-default-package-using-bndtools.

gjoranv
  • 4,376
  • 3
  • 21
  • 37
  • Thanks for the response!! – Johna Jun 01 '18 at 05:47
  • If it was helpful and you were able to resolve the problem, please accept the answer so others don't waste time. If not, please add a comment describing why, and I will try to clarify. – gjoranv Jun 01 '18 at 06:39