【问题标题】:How to exclude a named package from a dependency that exists in another dependency using Maven Bundle Plugin (BND)?如何使用 Maven Bundle Plugin (BND) 从存在于另一个依赖项中的依赖项中排除命名包?
【发布时间】:2012-10-12 06:37:23
【问题描述】:

我有两个依赖项:

<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>

两个依赖导出包:

  • org.postgres

使用 Maven Bundle Plugin 的 wrap 命令时,如何排除从 postgis-jdbc 导出 org.postgres

【问题讨论】:

    标签: java osgi bnd maven-bundle-plugin


    【解决方案1】:

    将以下内容添加到 pom 中的配置部分:

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

    或者你可能会忽略任何包

    <Export-Package>!*</Export-Package>
    

    【讨论】:

      【解决方案2】:

      使用 Maven 捆绑插件,我找不到一种实用的方法来选择性地排除选定包装依赖项的包导出。我的解决方案是在我的包中同时嵌入 com.springsource.org.postgresql.jdbc4postgis-jdbc,而不是导出它们的包:

      <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>
      

      【讨论】:

        猜你喜欢
        • 2020-03-02
        • 2016-09-21
        • 2012-04-20
        • 2020-02-15
        • 1970-01-01
        • 1970-01-01
        • 2017-06-15
        • 2017-07-11
        • 2012-02-25
        相关资源
        最近更新 更多