尝试在 Maven 中构建具有嵌入式依赖项的 OSGi 包。似乎无法从 BND 类路径中排除传递依赖项

2024-03-30

基本上,我的 Web 服务必须可部署为单个 OSGi jar 包。所以:

  1. 该包必须包含所有编译和运行时 Maven 依赖项。
  2. 它还必须包含依赖于这些依赖项的所有非可选依赖项(即传递依赖项)。

我正在尝试使用 maven-bundle-plugin 来完成此任务。我使用 Embed-Dependency 获取捆绑包中的所有编译和运行时依赖项,并使用 Embed-Transitive 嵌入所有传递依赖项。然后我想出了如何使用 exceptDependency 从 BND 类路径中排除 Maven 依赖项(它们被移动到清单中的 Private-Package 中),但对于我来说,我无法弄清楚如何让它排除传递依赖项。无论我做什么,传递依赖项似乎仍然显示在清单中的导入包列表中。

更糟糕的是,它似乎吸收了所有依赖项,包括可选的依赖项,所以我得到了很多我不使用的额外东西,比如 ibatis 和 jfree。然而,当我将 ;optical=false 添加到依赖项模式时,我收到一条警告,指出没有依赖项与该模式匹配。

我开始尝试一一排除依赖项,但经过一小时的追踪依赖项后,我决定必须有一种更好的方法。

这是我的 pom.xml 的当前版本。谁能帮我解决这个问题吗?

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
    <artifactId>direct-parent</artifactId>
    <groupId>com.edo.direct</groupId>
    <version>1.0-SNAPSHOT</version>
    <relativePath>../direct-parent</relativePath>
</parent>

<artifactId>direct-registration</artifactId>
<packaging>bundle</packaging>

<repositories>
    <repository>
        <id>wso2</id>
        <url>http://dist.wso2.org/maven2/</url>
    </repository>
</repositories>

<build>
    <plugins>

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>2.3.5</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>bundle</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <excludeDependencies>*;scope=compile|runtime</excludeDependencies>
                <ignoreMissingArtifacts>true</ignoreMissingArtifacts>
                <instructions>
                    <Bundle-Vendor>edo Interactive</Bundle-Vendor>
                    <Bundle-SymbolicName>com.edo.direct.service</Bundle-SymbolicName>
                    <Export-Package>
                        com.edo.service;-split-package:=merge-first
                    </Export-Package>
                    <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                    <Embed-Transitive>true</Embed-Transitive>
                    <Import-Package>
                        *
                    </Import-Package>
                    <Private-Package>
                        com.edo*;-split-package:=merge-first,
                    </Private-Package>
                    <Include-Resource>
                        {maven-resources}
                    </Include-Resource>
                    <Bundle-ClassPath>.,{maven-dependencies}</Bundle-ClassPath>
                </instructions>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.9</version>
            <configuration>
                <includes>
                    <include>**/*Test.java</include>
                </includes>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/main/groovy</source>
                        </sources>
                    </configuration>
                </execution>
                <execution>
                    <id>add-test-source</id>
                    <phase>generate-test-sources</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/test/groovy</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.3.1</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
                <verbose>true</verbose>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>1.8.0-03</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.5.1</version>
                    <exclusions>
                        <exclusion>
                            <groupId>org.codehaus.groovy</groupId>
                            <artifactId>groovy-eclipse-batch</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.mojo</groupId>
                                    <artifactId>build-helper-maven-plugin</artifactId>
                                    <versionRange>[1.5,)</versionRange>
                                    <goals>
                                        <goal>add-source</goal>
                                        <goal>add-test-source</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.apache.maven.plugins</groupId>
                                    <artifactId>maven-compiler-plugin</artifactId>
                                    <versionRange>[2.3.1,)</versionRange>
                                    <goals>
                                        <goal>testCompile</goal>
                                        <goal>compile</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>org.codehaus.groovy</groupId>
                                    <artifactId>groovy-eclipse-compiler</artifactId>
                                    <versionRange>[2.5.1,)</versionRange>
                                    <goals>
                                        <goal>testCompile</goal>
                                        <goal>compile</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <execute />
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>

<name>direct-registration</name>
<url>http://maven.apache.org</url>

<properties>
    <gmaven.version>1.3</gmaven.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.9</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.axis2.wso2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.6.0.wso2v4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-kernel</artifactId>
        <version>1.6-wso2v4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2</artifactId>
        <version>1.6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-kernel</artifactId>
        <version>1.6.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.axis2</groupId>
        <artifactId>axis2-spring</artifactId>
        <version>1.6.0</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-orm</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-webmvc</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-asm</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-config</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-web</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.springframework.security</groupId>
        <artifactId>spring-security-ldap</artifactId>
        <version>3.0.5.RELEASE</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>org.grails</groupId>
        <artifactId>grails-spring</artifactId>
        <version>1.3.7</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-validator</artifactId>
        <version>4.2.0.Final</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-core</artifactId>
        <version>3.6.5.Final</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-ehcache</artifactId>
        <version>3.6.5.Final</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.hibernate.javax.persistence</groupId>
        <artifactId>hibernate-jpa-2.0-api</artifactId>
        <version>1.0.0.Final</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <version>9.0-801.jdbc4</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>javassist</groupId>
        <artifactId>javassist</artifactId>
        <version>3.12.1.GA</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>cglib</groupId>
        <artifactId>cglib</artifactId>
        <version>2.2.2</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>net.sf.ehcache</groupId>
        <artifactId>ehcache-core</artifactId>
        <version>2.4.3</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>com.google.collections</groupId>
        <artifactId>google-collections</artifactId>
        <version>1.0</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.0.1</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>commons-codec</groupId>
        <artifactId>commons-codec</artifactId>
        <version>1.5</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>joda-time</groupId>
        <artifactId>joda-time</artifactId>
        <version>1.6.2</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>

    <dependency>
        <groupId>commons-logging</groupId>
        <artifactId>commons-logging</artifactId>
        <version>1.1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.5.10</version>
        <scope>compile</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.5.10</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jcl-over-slf4j</artifactId>
        <version>1.5.10</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>jul-to-slf4j</artifactId>
        <version>1.5.10</version>
        <scope>runtime</scope>
        <optional>false</optional>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>provided</scope>
    </dependency>

    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-osgi-locator</artifactId>
        <version>1.1</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.geronimo.specs</groupId>
        <artifactId>geronimo-jaxrs_1.1_spec</artifactId>
        <version>1.0</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
        <scope>provided</scope>
    </dependency>

    <!-- Project Dependencies -->
    <dependency>
        <groupId>${project.groupId}</groupId>
        <artifactId>direct-common</artifactId>
        <version>${project.version}</version>
    </dependency>
</dependencies>
</project>

我遇到了类似的问题,我使用 tycho build,但我的捆绑包之一是使用 BND 构建的。看http://code.google.com/p/choncms/source/browse/trunk/chon-platform/bnd-libs/pom.xml http://code.google.com/p/choncms/source/browse/trunk/chon-platform/bnd-libs/pom.xml,在 Import-Package 中,我使用 !* 来排除所有依赖项,除非明确提到了必要的依赖项。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

尝试在 Maven 中构建具有嵌入式依赖项的 OSGi 包。似乎无法从 BND 类路径中排除传递依赖项 的相关文章

随机推荐

  • 如何自定义散点图中的标记颜色和形状? [复制]

    这个问题在这里已经有答案了 我有一个包含 9 列的数据集 7 个特征用于特征选择 其中一个用于分类 我使用 tsne 库进行特征选择 以查看我的数据可以分类多少 tsne 的结果如图所示 但是 我想以另一种方式可视化我的数据 我想根据 f1
  • 为什么 New Date() 总是返回 null?

    如果日期格式是 scope timestamp 2016 12 16 07 02 15 am 我想格式化为16 12 2016 07 02 15 am 我已经尝试过下面的代码并且运行良好 scope originalStamp filter
  • 尝试汇编反汇编器的输出(例如 objdump)[重复]

    这个问题在这里已经有答案了 可能的重复 反汇编 修改然后重新组装 Linux 可执行文件 https stackoverflow com questions 4309771 disassembling modifying and then
  • Liferay:登录 Liferay 的默认方法是什么?

    通过开发 portlet hooks 等 我看到了在 Liferay 中登录的不同方法 是否有我可以使用的默认日志记录方法 Liferay Way 1 如何初始化记录器 2 如何配置日志级别 我看到可以直接在Liferay 控制面板中修改日
  • 监控 Android 手机中的网络活动

    我想监控我的 Android 手机的网络流量 我正在考虑在 Android 上使用 tcpdump 但我不确定是否必须为手机进行交叉编译 另一个问题是 如果我想监控某个应用程序的流量数据 有什么命令可以做到这一点吗 TCPDUMP 是我最喜
  • 当 url 模式是路径时,无法让 Spring MVC 调度程序正常工作

    我有一个网络应用程序 目前我们正在将 Spring MVC 应用到 REST 服务 我们希望我们的休息服务出现在 contextPath rest 但是当我设置这个时 我们得到 在名称为 Spring MVC Dispatcher Serv
  • 如何使用另一个数据库(非默认数据库)中的 auth_user?

    我有两个数据库 默认数据库和示例数据库 我想用auth user来自示例数据库而不是来自默认数据库的表 默认情况下 它是从默认数据库获取的 我想在我的模型文件中指定它 以便我可以在我的视图中访问 这怎么可能 DATABASES defaul
  • 在Python中创建饼图

    我已经创建了饼图 但现在我正在使用一系列单元格 如下所示 chart3 add series name Pie data categories Pivots A 3 A 10 values Pivots F 3 F 10 这为我提供了一个饼
  • 按列对多维关联数组进行排序并保留第一级键

    我有一个看起来像这样的数组 this gt wordswithdata team1 gt points gt 10 players gt team2 gt points gt 23 players gt 我想按照每支球队的得分从高到低对球队
  • 新的 ms botbuilder 直线语音是否适合呼叫中心场景?

    MS 最近推出了直接语音通道以及一些供 Web 前端使用它的示例 但我想知道它是否适合在使用某些 SIP 或 twilio 电话等服务的呼叫中心场景中使用 如果是这样 我想看看一些文档如何使用直线语音 api 并将其连接到某些电话 我已经创
  • Linux 上的 cp + git 基准测试与 Linux 上的基准测试Windows:为什么会有这样的差异?

    我用这个创建了大量文件Python脚本 https gist github com nowox fd62b89b69ea730f3dbd0969e7693fbe我主要用它来对 Git 进行基准测试 结果非常令人惊讶 尤其是 Windows
  • 如何更改 ASP.NET Core API 中的默认控制器和操作?

    我正在创建一个 ASP NET Core API 应用程序 目前 当创建一个新项目时 会有一个名为 Values 的控制器 默认情况下 API 会在您运行时打开它 因此 我删除了该控制器并添加了一个名为 Intro 的新控制器 并在其中添加
  • pyodbc rowcount 只返回 -1

    行计数如何工作 我正在使用 pyodbc 它总是返回 1 return query conn query db param query q params print return query rowcount def query db pa
  • MSBuild 构建前步骤

    我昨天问了关于获得AfterBuild工作并能够通过将其放置在最底部来使其工作Project部分 MSBuild AfterBuild 步骤 https stackoverflow com q 26760052 2642059 我在不同的项
  • 无法在 websphere 8.5 上启动应用程序,但在版本 7 上运行

    我遇到了一个特殊的问题 我有一个包含 ejb jar 的 Ear 应用程序在 websphere 7 上独立运行 我下载了 8 5 试用版 创建了一个垂直集群并在其上安装了应用程序 但该应用程序在 8 5 版本上尚未启动 每次我尝试启动它时
  • 如何删除头部?

    我错误地推送了一些文件 它在主存储库中显示了不同的头 我怎样才能删除那个头 您可以通过编辑您的文件来启用 mq 扩展 hgrc文件 确保存在以下行 extensions mq 之后 您可以 剥离 特定修订版 将其删除 这样您就只有一个头 h
  • 测试依赖于 NUnit 的常用功能

    我有一些初始化代码来使用我的 API 初始化可能会失败 我想在 NUnit 测试中测试它 初始化之后就可以使用API 了 我也在测试 API 但我所有的测试方法都将使用相同的 通用的初始化代码 我理想的情况是这种行为 运行初始化测试 如果
  • Java 8 流 - 超时?

    我想循环一个巨大的数组并执行一组需要很长时间的复杂指令 但是 如果超过 30 秒 我希望它放弃 ex final long start System currentTimeMillis myDataStructure stream whil
  • Swift 数字和 CGFloat(CGPoint、CGRect 等)

    我发现 Swift 数字特别笨拙 就像现实生活中经常发生的那样 我必须与 Cocoa Touch 就 CGRect 和 CGPoint 进行交流 例如 因为我们正在谈论某事frame or bounds CGFloat 与 Double 考
  • 尝试在 Maven 中构建具有嵌入式依赖项的 OSGi 包。似乎无法从 BND 类路径中排除传递依赖项

    基本上 我的 Web 服务必须可部署为单个 OSGi jar 包 所以 该包必须包含所有编译和运行时 Maven 依赖项 它还必须包含依赖于这些依赖项的所有非可选依赖项 即传递依赖项 我正在尝试使用 maven bundle plugin