Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用maven bundle插件从导入包中排除版本号?_Maven_Eclipse Plugin_Osgi_Apache Felix - Fatal编程技术网

如何使用maven bundle插件从导入包中排除版本号?

如何使用maven bundle插件从导入包中排除版本号?,maven,eclipse-plugin,osgi,apache-felix,Maven,Eclipse Plugin,Osgi,Apache Felix,maven bundle插件生成的MANIFEST.MF有问题。出于某种原因,当我在字段中列出了版本号时,OSGi框架不会加载我的捆绑包 我已经做过实验,并注意到如果我删除清单中的版本号,那么捆绑包就会正确加载 如何指示maven bundle插件跳过版本号 目前,它生成: Import-Package: com.ghc.ghTester.expressions,org.apache.ws.security.proc essor;version="[1.5,2)",org.apache.ws.

maven bundle插件生成的MANIFEST.MF有问题。出于某种原因,当我在
字段中列出了版本号时,OSGi框架不会加载我的捆绑包

我已经做过实验,并注意到如果我删除清单中的版本号,那么捆绑包就会正确加载

如何指示maven bundle插件跳过版本号

目前,它生成:

Import-Package: com.ghc.ghTester.expressions,org.apache.ws.security.proc
 essor;version="[1.5,2)",org.apache.ws.security;version="[1.5,2)",org.ap
 ache.ws.security.message;version="[1.5,2)",org.apache.ws.security.compo
 nents.crypto;version="[1.5,2)",org.apache.ws.security.message.token;ver
 sion="[1.5,2)"
但我需要它来产生:

导入包:com.ghc.ghTester.expressions,org.apache.ws.security.proc essor,org.apache.ws.security,org.apache.ws.security.message,org.apache。 ws.security.components.crypto,org.apache.ws.security.message.token

我的插件配置是:

        <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <version>3.0.0</version>
            <extensions>true</extensions>
            <configuration>
                <instructions>
                    <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId};singleton:=true</Bundle-SymbolicName>
                    <Bundle-Name>${pom.name}</Bundle-Name>
                    <Bundle-Version>${pom.version}</Bundle-Version>
                    <Bundle-ClassPath>{maven-dependencies},.</Bundle-ClassPath>
                    <Embed-Dependency>*;scope=compile</Embed-Dependency>
                    <Export-Package/> <!-- nothing for this bundle to export -->
                    <Import-Package>com.ghc.ghTester.expressions,org.apache.ws.*</Import-Package>
                </instructions>
            </configuration>
        </plugin>

您可以像使用“com.ghc.ghter.expressions”一样手动编写导入


com.ghc.ghter.expressions,
org.apache.ws.security.processor,
org.apache.ws.security,
org.apache.ws.security.message,
org.apache.ws.security.components.crypto,
org.apache.ws.security.message.token
尽管这不是评论中提到的好做法,但它应该起作用。但如果以后需要其他导入,也必须手动添加。

顺便说一句价值观

<Bundle-Name>${pom.name}</Bundle-Name>
<Bundle-Version>${pom.version}</Bundle-Version>
${pom.name}
${pom.version}
不要默认为您提供的值。看见
部分:默认行为

您可以使用以下配置禁用导入包版本:

<_consumer-policy>$${range;[--,++)}</_consumer-policy>
$${range;[-,++)}

导入包
部分中的
版本=!
添加到每个要从中省略版本的捆绑包中即可

<Import-Package>
    com.ghc.ghTester.expressions;version=!,
    org.apache.ws.security.processor;version=!,
    org.apache.ws.security;version=!,
    org.apache.ws.security.message;version=!,
    org.apache.ws.security.components.crypto;version=!,
    org.apache.ws.security.message.token;version=!,
    *
</Import-Package>

expressions;版本=!,
org.apache.ws.security.processor;版本=!,
org.apache.ws.security;版本=!,
org.apache.ws.security.message;版本=!,
org.apache.ws.security.components.crypto;版本=!,
org.apache.ws.security.message.token;版本=!,
*

忽略版本不是一个好做法。部署捆绑包时会出现什么错误?您不能使用依赖项部署的版本?我知道这不是一个好做法,但这是一个非常有限的插件,将在非常有限的框架中使用。框架完全不在我的控制范围内,我不知道甚至在我尝试加载捆绑包时也会看到错误消息。通过试用和出错,我注意到是版本号导致了问题,而最简单的规避方法就是删除版本。如果您使用felix,您可以使用gogo shell上的
exports
命令来查找导出的包的版本?I不要认为有了这个插件就可以忽略这个版本。可能类似于
version=[0,9)
可以工作,但它确实很难看,并且违背了osgiI依赖项管理的目的。最终,osgiI成功注销了一些日志,并粘贴了上面的错误。基本上,找不到版本。您可以定义:packageName;version=“0”。这意味着接受所有版本,就好像没有指定范围一样,这意味着大于或等于指定的版本。并使用前面一条注释中提到的双代号。
<_consumer-policy>$${range;[--,++)}</_consumer-policy>
<Import-Package>
    com.ghc.ghTester.expressions;version=!,
    org.apache.ws.security.processor;version=!,
    org.apache.ws.security;version=!,
    org.apache.ws.security.message;version=!,
    org.apache.ws.security.components.crypto;version=!,
    org.apache.ws.security.message.token;version=!,
    *
</Import-Package>