How to exclude a named package from a dependency that exists in another dependency using Maven Bundle Plugin (BND)?

StackOverflow https://stackoverflow.com/questions/13011654

Question

I have two dependencies:

<dependency>
    <groupId>org.postgis</groupId>
    <artifactId>postgis-jdbc</artifactId>
    <version>1.5.2</version>
</dependency>
<dependency>
    <groupId>org.postgresql</groupId>
    <artifactId>com.springsource.org.postgresql.jdbc4</artifactId>
    <version>8.3.604</version>
</dependency>

Both dependencies export package:

  • org.postgres

How can I exclude exporting org.postgres from postgis-jdbc when using the Maven Bundle Plugin's wrap command?

Was it helpful?

Solution 2

Using the Maven Bundle Plugin, I couldn't find a practical way of selectively excluding package exports for selected wrapped dependencies. My solution was to instead embed both com.springsource.org.postgresql.jdbc4 and postgis-jdbc in my bundle, and not export their packages:

<plugin>
    <groupId>org.apache.felix</groupId>
    <artifactId>maven-bundle-plugin</artifactId>
    <version>2.3.7</version>
    <extensions>true</extensions>
    <configuration>
      <instructions>
            ...
            <Embed-Dependency>
                postgresql;postgis-jdbc
            </Embed-Dependency>
            ...
        </instructions>
    </configuration>
    <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>bundle</goal>
           </goals>
        </execution>
    </executions>
</plugin>

OTHER TIPS

Add the following to your config section in the pom:

<Export-Package>!org.postgres</Export-Package>

Or you might ignore any package by

<Export-Package>!*</Export-Package>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top